diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-05 19:02:43 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-05-05 19:02:43 +0200 |
commit | f5b5f72f7eaf14692b8036c3698037c647b2423a (patch) | |
tree | f74eb37277771fd1dceec702d1f3820fb553dc2a /templates/base.qtpl | |
parent | 129c73757036a8073467a2046bc73e95918f1ca1 (diff) | |
download | cerrado-f5b5f72f7eaf14692b8036c3698037c647b2423a.tar.gz cerrado-f5b5f72f7eaf14692b8036c3698037c647b2423a.tar.bz2 cerrado-f5b5f72f7eaf14692b8036c3698037c647b2423a.zip |
feat: Add qtc templating
Diffstat (limited to 'templates/base.qtpl')
-rw-r--r-- | templates/base.qtpl | 44 |
1 files changed, 44 insertions, 0 deletions
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) %} +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>img | {%= p.Title() %}</title> + <link rel="stylesheet" href="/static/main.css"> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + </head> + <body> + <div> + {%= p.Content() %} + </div> + </body> + {%= p.Script() %} +</html> +{% endfunc %} + +{% code type BasePage struct {} %} +{% func (p *BasePage) Title() %}Empty{% endfunc %} +{% func (p *BasePage) Body() %}HelloWorld{% endfunc %} +{% func (p *BasePage) Script() %}{% endfunc %} |