Skip to content
Thanatat Tamtan edited this page Jun 9, 2026 · 4 revisions

When some templates have to be used for multiple views, preload can be used 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