Classes | |
class | TemplateVariant |
Variant type which can hold one value of a fixed set of types. More... | |
class | TemplateAutoRef< T > |
class | TemplateListIntf |
Abstract read-only interface for a context value of type list. More... | |
class | TemplateList |
Default implementation of a context value of type list. More... | |
class | TemplateStructIntf |
Abstract interface for a context value of type struct. More... | |
class | TemplateStruct |
Default implementation of a context value of type struct. More... | |
class | TemplateEscapeIntf |
Interface used to escape characters in a string. More... | |
class | TemplateSpacelessIntf |
Interface used to remove redundant spaces inside a spaceless block. More... | |
class | TemplateContext |
Abstract interface for a template context. More... | |
class | Template |
Abstract interface for a template. More... | |
class | TemplateEngine |
Engine to create templates and template contexts. More... | |
This is the API for a Django compatible template system written in C++. It is somewhat inspired by Stephen Kelly's Grantlee.
A template is simply a text file. A template contains variables, which get replaced with values when the template is evaluated, and tags, which control the logic of the template.
Variables look like this: {{ variable }}
When the template engine encounters a variable, it evaluates that variable and replaces it with the result. Variable names consist of any combination of alphanumeric characters and the underscore ("_"). Use a dot (.) to access attributes of a structured variable.
One can modify variables for display by using filters, for example: {{ value|default:"nothing" }}
Tags look like this: {% tag %}
. Tags are more complex than variables: Some create text in the output, some control flow by performing loops or logic, and some load external information into the template to be used by later variables.
To comment-out part of a line in a template, use the comment syntax: {# comment text #}
.
Supported Django tags:
for ... empty ... endfor
if ... else ... endif
block ... endblock
extend
include
with ... endwith
spaceless ... endspaceless
cycle
Extension tags:
create
which instantiates a template and writes the result to a file. The syntax is `{% create 'filename' from 'template' %}. -
recursetree -
markers -
msg...
endmsg -
set`Supported Django filters:
default
length
add
divisibleby
Extension filters:
stripPath
nowrap
prepend
append