Struct bracket::render::Render [−][src]
pub struct Render<'render> { /* fields omitted */ }
Expand description
Render a template.
Implementations
Create a renderer.
You should not need to create a renderer directly, instead
use the functions provided by the Registry
.
Get the name of the template being rendered.
This will equal the name given when the renderer is started and does not account for partials; to get the name of a template including the current partial use current_name().
Get the current name for the template being rendered.
When a partial is being rendered this will return the name for the current partial otherwise it falls back to the name given when the renderer was started.
When partials have been loaded from the file system
the name will be the file path and should be safe to
pass to PathBuf::from
to get a reference to the original file.
It is the caller’s responsiblity to account for relative paths when converting template names to paths.
Render template string content and return the buffered result.
The current call site stack is cloned and used in a new render pass so that cyclic calls can be detected before the stack overflows.
Use this function when a helper wants to render a dynamic template but needs to prevent a stack overflow when a cyclic call is detected.
Render a node by iterating it’s children.
The supplied node should be a document or block node.
Get a named template.
Get a mutable reference to the output destination.
You should prefer the write()
and write_escaped()
functions
when writing strings but if you want to write bytes directly to
the output destination you can use this reference.
Write a string to the output destination.
Write a string to the output destination and escape the content using the current escape function.
Push a scope onto the stack.
Evaluate the block conditionals and find the first node that should be rendered.
Render an inner template.
Block helpers should call this when they want to render an inner template.
Render a node and buffer the result to a string.
The call stack and scopes are inherited from this renderer.
The supplied node should be a document or block node.
Evaluate a path and return the resolved value.
This allows helpers to find variables in the template data
using the familiar path syntax such as @root.name
.
Paths are evaluated using the current scope so local variables in the current scope will be resolved.
Paths are dynamically evaluated so syntax errors are caught and
returned wrapped as HelperError
.
Sub-expressions are not executed.
Evaluate a path and perform a type assertion on the value.
If no value exists for the given path the value is treated as null and type assertion is performed on the null value.
pub fn register_local_helper(
&mut self,
name: &'render str,
helper: Box<dyn LocalHelper + 'render>
)
pub fn register_local_helper(
&mut self,
name: &'render str,
helper: Box<dyn LocalHelper + 'render>
)
Register a local helper.
Local helpers are available for the scope of the parent helper.
Remove a local helper.
Local helpers will be removed once a helper call has finished but you can call this if you want to be explicit.