[−][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) -> 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]
pub 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.
pub 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.
pub fn try_from(value: TemplateTree) -> Result<Self>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Template
[src]
impl Send for Template
[src]
impl Sync for Template
[src]
impl Unpin for Template
[src]
impl !UnwindSafe for Template
[src]
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,