I use standard go template.
There are 2 questions
1. It is necessary to start the function prescribed in the template itself.
2. It is necessary to connect the file prescribed in the template.

Well, something like this

<html> {{ GetFile "/tpl/myfile.tpl" }} {{ SayHello }} //а функция возратит текст </html> 

How to implement this?
I read the docks, but I can't dynamically connect the files, only in the go code there are examples, and even with the functions, the dance with tambourines is something.

1 answer 1

To include the code of another template use

 {{template "base/footer.html"}} 

To use their functions are written FuncMap (package "html / template"):

  func loadTemplate(Name string) *html.Template { funcMap := html.FuncMap{ "foo": func(val string) html.HTML { return html.HTML(val) }, } return html.Must(html.New("*").Funcs(funcMap).Delims("{{", "}}").ParseFiles("template/" + Name + ".tpl")) } 

Then in the template we use this:

 <h1>{{ .var | foo }}</h1>