Skip to content
Thanatat Tamtan edited this page Sep 23, 2023 · 3 revisions

When some template have to use for multiple view, preload can be use in this case.

For example

t := app.Template()
t.ParseFiles("index", "index.tmpl", "layout.tmpl", "footer.tmpl").
t.ParseFiles("about-us", "about-us.tmpl", "layout.tmpl", "footer.tmpl")

Can rewrite to use preload

t := app.Template()
t.Preload("layout.tmpl", "footer.tmpl").
t.ParseFiles("index", "index.tmpl").
t.ParseFiles("about-us", "about-us.tmpl")

Next, see how to Config hime from file.

And see how to load html/template into template using Component

Clone this wiki locally