{% import ( "runtime/debug" "golang.org/x/text/language" "golang.org/x/text/message" ) %} {% interface Page { body() head() lang() t(format message.Reference, args ...any) title() } %} {% code type BaseOf struct { language language.Tag printer *message.Printer name string } func NewBaseOf(lang language.Tag, name string) *BaseOf { return &BaseOf{ language: lang, printer: message.NewPrinter(lang), name: name, } } %} {% collapsespace %} {% func (p *BaseOf) lang() %} {%s p.language.String() %} {% endfunc %} {% func (p *BaseOf) title() %} {%s p.name %} {% endfunc %} {% func (p *BaseOf) head() %} {% comment %}https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs{% endcomment %} {% endfunc %} {% func (p *BaseOf) body() %}{% endfunc %} {% func (p *BaseOf) t(format message.Reference, args ...any) %} {%s p.printer.Sprintf(format, args...) %} {% endfunc %} {% func Template(p Page) %} {%= p.title() %} {%= p.head() %} {%= p.body() %} {% code var path, vcsRevision string if bi, ok := debug.ReadBuildInfo(); ok { path = bi.Path for i := range bi.Settings { if bi.Settings[i].Key != "vcs.revision" { continue } vcsRevision = bi.Settings[i].Value } } %} {% endfunc %} {% endcollapsespace %}