glemplate/ast
The abstract syntax tree that templates are stored as in memory. This AST can be rendered with the renderer module.
Types
A dynamic node is used for dynamic behaviour in a template.
pub type DynamicNode {
Output(Var)
RawOutput(Var)
If(Var, if_true: List(Node), if_false: List(Node))
Iter(over: Var, binding: String, nodes: List(Node))
Render(tpl: String, assigns_map: List(#(Var, String)))
}
Constructors
-
Output(Var)Output the variable, encoded.
-
RawOutput(Var)Output the variable, without encoding.
-
Render a node list based on if the assign is truthy.
Truthy values are all values except
False,0, or empty strings, lists, or dicts. -
Iterate over the variable, bind it to a new name, and render the node list for every item.
-
Render(tpl: String, assigns_map: List(#(Var, String)))Render the given template, using the assigns mapping. The assigns mapping is a list of tuples
(from, to), where thefromnamed assigns are available withtonames in the child template.
pub type Node {
Text(String)
Dynamic(DynamicNode)
Nodes(nodes: List(Node))
}
Constructors
-
Text(String) -
Dynamic(DynamicNode) -
Nodes(nodes: List(Node))
A reference to a template with the given name.
pub type TemplateName =
String