Usually you’ll need pages a little bit more complex than just a Str with substitution variables. That’s where you’ll need templates.
Templates are simple text files (html, xml, csv, etc.) with special instructions in them. For now, Spectre comes with built-in support for Mustache templates only. You can find a really short introduction to Musatche syntax on their website.
The recommended way to deal with templating is to return TemplateRes object from the view and then intercept it and render in template rendering middleware. This decouples view from presentation details and leaves you a place to do something site-wide with TemplateRes after it was returned from view (e.g. populate context with some site-wide attributes like current user’s name, or change path to template basing on client’s platform, moving this logic out of view).
First, create templates/ folder somewhere inside your app’s folder (it’s just a convention, you are free to choose any name you want).
Set up renderer by assigning MustacheRenderer instance to Settings.rendered field:
renderer = MustacheRenderer([appDir + `templates/`])
Then, create a template file inside templates/ folder, for example index.html:

Hello from other world, {{name}}!

You have just won ${{value}}!

{{#in_ca}}
Well, ${{taxed_value}}, after taxes.
{{/in_ca}}
Finally, return TemplateRes instead of Res from view:
Res index(Req req, Session session) {
context := ["name": session["current_user"].name,
"value": 200,
"in_ca": true,
"taxed_value": 15]
return TemplateRes("index.html", context)
}
When intercepted by MustacheRenderer, TemplateRes will be rendered using TemplateRes.template and TemplateRes.context, and result will be stored in TemplateRes.content. After that, TemplateRes will be used as a typical Res instance — returned from app, its content will be sent to the client.
Value in inclusion tag is first looked up against context, and, if not found, is used as-is. Following template:
{{> content }}
with context:
{"content": "page.html"}
will include page.html, but the very same template without "content" in context will try to include "content" template.


selects each 3rd paragraph, starting at the last 2nd child element (in this case the eight p element).
The first paragraph.
The second paragraph.
The third paragraph.
The fourth paragraph.
The fifth paragraph.
The sixth paragraph.
The seventh paragraph.
The eight paragraph.
This is a span element.