Templates

dynamic HTML pages from a templating engine with full Go support

This project uses quicktemplate for HTML and SQL templating. For HTML, a top-level page is expected to define a struct that embeds layout.Basic (or some other layout) and implements layout.Page.

A simple page would look like this:

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{% import (
"myproject/app"
"myproject/app/controller/cutil"
"myproject/app/util"
"myproject/views/components"
"myproject/views/layout"
) %}

{% code type Basic struct {
layout.Basic
MOTD string
} %}

{% func (p *Basic) Body(as *app.State, ps *cutil.PageState) %}
<div class="card">
<h3>{%= components.SVGIcon(`app`, ps) %} {%s util.AppName %}</h3>
<div class="mt">
<p>This is my app!</p>
</div>
</div>
{% endfunc %}