package main
import (
"text/template"
"os"
)
var fm = template.FuncMap{
"mul2": double,
}
func double(x float64) float64 {
return x * 2
}
var x = 10.0
var tpl *template.Template
func main() {
tpl = template.Must(template.New("").Funcs(fm).ParseFiles("templates/index.html"))
tpl.ExecuteTemplate(os.Stdout,"index.html" , x) //This line works
tpl.Execute(os.Stdout, x) // This line does not show any output.
}
Only when I specify which template to execute, it works otherwise it doesn’t.
Any Idea?