This is a base page template. All the other template pages implement this interface. {% import "strconv" %} {% import "time" %} {% code var Slug = "" %} {% interface Page { Title() Content() Script() Navbar() } %} {% code func FromUInttoString(u *uint) string { if u != nil { return strconv.FormatUint(uint64(*u), 10) } return "" } %} {% code func TimeFormat(t time.Time) string { return t.Format("2006-01-02") } %} {% code func Ignore[T any](v T, _ error) T { return v } %} Page prints a page implementing Page interface. {% func PageTemplate(p Page) %} cerrado | {%= p.Title() %} {%= p.Navbar() %}
{%= p.Content() %}
{%= p.Script() %} {% endfunc %} {% code type BasePage struct {} %} {% func (p *BasePage) Title() %}Empty{% endfunc %} {% func (p *BasePage) Body() %}HelloWorld{% endfunc %} {% func (p *BasePage) Script() %}{% endfunc %}