Doxygen
Template API

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:

Extension tags:

Supported Django filters:

Extension filters:

类型定义说明

◆ TemplateVariantList

using TemplateVariantList = std::vector<TemplateVariant>

在文件 template.h261 行定义.