[][src]Struct ramhorns::Template

pub struct Template<'tpl> { /* fields omitted */ }

A preprocessed form of the plain text template, ready to be rendered with data contained in types implementing the Content trait.

Methods

impl<'tpl> Template<'tpl>[src]

pub fn new<Source>(source: Source) -> Result<Self, Error> where
    Source: Into<Cow<'tpl, str>>, 
[src]

Create a new Template out of the source.

  • If Source is a &str, this Template will borrow it with appropriate lifetime.
  • If Source is a String, this Template will take it's ownership (The 'tpl lifetime will be 'static).

pub fn capacity_hint(&self) -> usize[src]

Estimate how big of a buffer should be allocated to render this Template.

pub fn render<C: Content>(&self, content: &C) -> String[src]

Render this Template with a given Content to a String.

pub fn render_to_writer<W, C>(&self, writer: &mut W, content: &C) -> Result<()> where
    W: Write,
    C: Content
[src]

Render this Template with a given Content to a writer.

pub fn render_to_file<P, C>(&self, path: P, content: &C) -> Result<()> where
    P: AsRef<Path>,
    C: Content
[src]

Render this Template with a given Content to a file.

pub fn source(&self) -> &str[src]

Get a reference to a source this Template was created from.

impl Template<'static>[src]

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>[src]

Create a template from a file.

let tpl = Template::from_file("./templates/my_template.html").unwrap();

Auto Trait Implementations

impl<'tpl> Send for Template<'tpl>

impl<'tpl> Sync for Template<'tpl>

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.