Struct upon::Renderer

source ·
pub struct Renderer<'render> { /* private fields */ }
Expand description

A renderer that interprets a compiled Template or TemplateRef.

This struct is created by one of the following functions:

Implementations§

source§

impl<'render> Renderer<'render>

source

pub fn with_template_fn<F>(self, template_fn: F) -> Self
where F: FnMut(&str) -> Result<&'render Template<'render>, String> + 'render,

Set a function that is called when a template is included.

This allows custom template resolution on a per render basis. The default is to look for the template with the exact matching name in the engine, i.e. the same as Engine::get_template.

source

pub fn with_max_include_depth(self, depth: usize) -> Self

Set the maximum length of the template render stack.

This is the maximum number of nested {% include ... %} statements that are allowed during rendering, as counted from the root template.

Defaults to the engine setting.

source

pub fn to_string(self) -> Result<String>

Render the template to a string.

source

pub fn to_writer<W>(self, w: W) -> Result<()>
where W: Write,

Render the template to the given writer.

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<'render> Unpin for Renderer<'render>

§

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

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.