Here’s a small example I just wrote for you to check out:
package main
import (
"html/template"
"log"
"os"
)
var t = template.Must(template.New("t").Parse("{{.Content}}"))
func main() {
data := struct {
Content template.HTML
}{
"<a href='#link'>Link</a>",
}
if err := t.Execute(os.Stdout, data); err != nil {
log.Fatalln(err)
}
}
The above will output the following: <a href='#link'>Link</a>
However if Content is set to a string type, the output will be: <a href='#link'>Link</a>
data := struct {
Content template.HTML
}{
"<a href='#link'>Link</a>",
}
Google translate
How can I use one of the ParseGlob function templates instead of the (< a href=’#link’>Link< /a>) code?
I want to insert the selected one of the templates into the main template.
An example for a greater understanding of me
data := struct {
Content template.HTML
}{
"news.tpl", // How do I specify the template file to be inserted here?
}
Thanks for the help