glemplate/renderer
The renderer is given the template AST and some assigns, which it will render into a string output.
Types
Function to encode potentially dangerous contents into the template in a safe way. E.g. encode text with HTML entities in an HTML template.
pub type EncoderFn =
fn(String) -> StringTree
pub type RenderError {
AssignNotFound(assign: ast.Var, assigns: Assigns)
AssignNotIterable(assign: ast.Var, assigns: Assigns)
AssignNotStringifiable(assign: ast.Var, assigns: Assigns)
AssignFieldNotFound(
assign: ast.Var,
field: String,
assigns: Assigns,
)
AssignNotFieldAccessible(assign: ast.Var, assigns: Assigns)
ChildTemplateNotFound(tpl_name: ast.TemplateName)
}
Constructors
-
AssignNotFound(assign: ast.Var, assigns: Assigns)
A referenced assign was not found.
-
AssignNotIterable(assign: ast.Var, assigns: Assigns)
A referenced assign was not iterable.
-
AssignNotStringifiable(assign: ast.Var, assigns: Assigns)
A referenced assign could not be stringified.
-
AssignFieldNotFound( assign: ast.Var, field: String, assigns: Assigns, )
A referenced assign didn’t have the requested field.
-
AssignNotFieldAccessible(assign: ast.Var, assigns: Assigns)
A referenced assign couldn’t be accessed with field access.
-
ChildTemplateNotFound(tpl_name: ast.TemplateName)
A referenced child template was not found in the template cache.
Rendering options:
encoder
: Encoder function to use, it should encode dynamic content in a safe way for this template type.template_cache
: A cache of templates that child templates are looked up from, when using Render nodes.
pub type RenderOptions {
RenderOptions(
encoder: EncoderFn,
template_cache: TemplateCache,
)
}
Constructors
-
RenderOptions(encoder: EncoderFn, template_cache: TemplateCache)
pub type RenderResult =
Result(StringTree, RenderError)
pub type StringifyError {
StringifyError
}
Constructors
-
StringifyError
A cache of templates to use for rendering child templates.
pub type TemplateCache =
Dict(ast.TemplateName, ast.Template)