[][src]Struct templar::Template

pub struct Template(_);

Template holds the prepared result of parsing a template. Because the template does not need to be reparsed, subsequent executions come at a low cost.

Implementations

impl Template[src]

pub fn render(&self, ctx: &impl Context) -> Result<String>[src]

Render a template as a string.

Usage


let t = Templar::global().parse_expression("5 + 5")?;
assert_eq!(t.render(&context)?, "10");

pub fn exec(&self, ctx: &impl Context) -> Data[src]

Execute a template, getting a InnerData from the unstructured crate as a result. many of the native rust types implement into() on InnerData making direct comparisons easy.

Usage


let t = Templar::global().parse_expression("5 + 5")?;
assert_eq!(*t.exec(&context), 10i64);

Trait Implementations

impl Clone for Template[src]

impl Debug for Template[src]

impl Default for Template[src]

impl From<Template> for TemplateTree[src]

impl TryFrom<Option<TemplateTree>> for Template[src]

type Error = TemplarError

The type returned in the event of a conversion error.

impl TryFrom<TemplateTree> for Template[src]

type Error = TemplarError

The type returned in the event of a conversion error.

Auto Trait Implementations

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.