[][src]Struct bracket::render::Render

pub struct Render<'render> { /* fields omitted */ }

Render a template.

Implementations

impl<'render> Render<'render>[src]

pub fn new<T>(
    strict: bool,
    escape: &'render EscapeFn,
    helpers: &'render HelperRegistry<'render>,
    templates: &'render Templates<'render>,
    name: &'render str,
    data: &T,
    writer: Box<&'render mut dyn Output>
) -> RenderResult<Self> where
    T: Serialize
[src]

Create a renderer.

You should not need to create a renderer directly, instead use the functions provided by the Registry.

pub fn render(&mut self, node: &'render Node<'render>) -> RenderResult<()>[src]

Render a node by iterating it's children.

The supplied node should be a document or block node.

pub fn out(&mut self) -> &mut Box<&'render mut dyn Output>[src]

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.

pub fn write(&mut self, s: &str) -> HelperResult<usize>[src]

Write a string to the output destination.

pub fn write_escaped(&mut self, s: &str) -> HelperResult<usize>[src]

Write a string to the output destination and escape the content using the current escape function.

pub fn push_scope(&mut self, scope: Scope)[src]

Push a scope onto the stack.

pub fn pop_scope(&mut self) -> Option<Scope>[src]

Remove a scope from the stack.

pub fn scope_mut(&mut self) -> Option<&mut Scope>[src]

Get a mutable reference to the current scope.

pub fn root(&self) -> &Value[src]

Reference to the root data for the render.

pub fn inverse<'a>(
    &mut self,
    template: &'a Node<'a>
) -> Result<Option<&'a Node<'a>>, HelperError>
[src]

Evaluate the block conditionals and find the first node that should be rendered.

pub fn template(
    &mut self,
    node: &'render Node<'render>
) -> Result<(), HelperError>
[src]

Render an inner template.

Block helpers should call this when they want to render an inner template.

pub fn buffer(
    &self,
    node: &'render Node<'render>
) -> Result<String, HelperError>
[src]

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.

pub fn evaluate<'a>(&'a self, value: &str) -> HelperResult<Option<&'a Value>>[src]

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.

pub fn register_local_helper(
    &mut self,
    name: &'render str,
    helper: Box<dyn LocalHelper + 'render>
)
[src]

Register a local helper.

Local helpers are available for the scope of the parent helper.

pub fn unregister_local_helper(&mut self, name: &'render str)[src]

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.

Auto Trait Implementations

impl<'render> !RefUnwindSafe for Render<'render>

impl<'render> !Send for Render<'render>

impl<'render> !Sync for Render<'render>

impl<'render> Unpin for Render<'render>

impl<'render> !UnwindSafe for Render<'render>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.