From f5b5f72f7eaf14692b8036c3698037c647b2423a Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 5 May 2024 19:02:43 +0200 Subject: feat: Add qtc templating --- templates/base.qtpl | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 templates/base.qtpl (limited to 'templates/base.qtpl') diff --git a/templates/base.qtpl b/templates/base.qtpl new file mode 100644 index 0000000..1683981 --- /dev/null +++ b/templates/base.qtpl @@ -0,0 +1,44 @@ +This is a base page template. All the other template pages implement this interface. + +{% import "strconv" %} + +{% interface +Page { + Title() + Content() + Script() +} + +%} + +{% code func FromUInttoString(u *uint) string { + if u != nil { + return strconv.FormatUint(uint64(*u), 10) + } + return "" + } +%} + + +Page prints a page implementing Page interface. +{% func PageTemplate(p Page) %} + + + + img | {%= p.Title() %} + + + + +
+ {%= 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 %} -- cgit v1.2.3