[−][src]Struct templar::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) -> Result<Document>[src]
Execute a template, getting a Document from the unstructured crate as a result.
many of the native rust types implement into() on Document 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]
fn from(t: Template) -> TemplateTree[src]
impl TryFrom<Option<TemplateTree>> for Template[src]
type Error = TemplarError
The type returned in the event of a conversion error.
fn try_from(value: Option<TemplateTree>) -> Result<Self>[src]
impl TryFrom<TemplateTree> for Template[src]
type Error = TemplarError
The type returned in the event of a conversion error.
fn try_from(value: TemplateTree) -> Result<Self>[src]
Auto Trait Implementations
impl !RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl !UnwindSafe for Template
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,