Doxygen
|
This is the API for a Django compatible template system written in C++. It is somewhat inspired by Stephen Kelly's Grantlee. 更多...
类 | |
class | TemplateVariant |
Variant type which can hold one value of a fixed set of types. 更多... | |
class | TemplateListIntf |
Abstract read-only interface for a context value of type list. 更多... | |
class | TemplateImmutableList |
Default implementation of a immutable context value of type list. 更多... | |
class | TemplateStructIntf |
Abstract interface for a context value of type struct. 更多... | |
class | TemplateImmutableStruct |
Default implementation of an immutable context value of type struct. 更多... | |
class | TemplateEscapeIntf |
Interface used to escape characters in a string 更多... | |
class | TemplateSpacelessIntf |
Interface used to remove redundant spaces inside a spaceless block 更多... | |
class | TemplateContext |
Abstract interface for a template context. 更多... | |
class | Template |
Abstract interface for a template. 更多... | |
class | TemplateEngine |
Engine to create templates and template contexts. 更多... | |
类型定义 | |
using | TemplateVariantList = std::vector< TemplateVariant > |
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
using TemplateVariantList = std::vector<TemplateVariant> |
在文件 template.h 第 261 行定义.