[][src]Struct bracket::registry::Registry

pub struct Registry<'reg> { /* fields omitted */ }

Registry is the entry point for compiling and rendering templates.

A template name is always required for error messages.

Implementations

impl<'reg> Registry<'reg>[src]

pub fn new() -> Self[src]

Create an empty registry.

pub fn set_strict(&mut self, strict: bool)[src]

Set the strict mode.

pub fn strict(&self) -> bool[src]

Get the strict mode.

pub fn set_escape(&mut self, escape: EscapeFn)[src]

Set the escape function for rendering.

pub fn escape(&self) -> &EscapeFn[src]

The escape function to use for rendering.

pub fn helpers(&self) -> &HelperRegistry<'reg>[src]

Helper registry.

pub fn helpers_mut(&mut self) -> &mut HelperRegistry<'reg>[src]

Mutable reference to the helper registry.

pub fn handlers(&self) -> &HandlerRegistry<'reg>[src]

Event handler registry.

pub fn handlers_mut(&mut self) -> &mut HandlerRegistry<'reg>[src]

Mutable reference to the event handler registry.

pub fn templates(&self) -> &Templates[src]

Templates collection.

pub fn get_template(&self, name: &str) -> Option<&Template>[src]

Get a named template.

pub fn insert<N, C>(&mut self, name: N, content: C) -> Result<()> where
    N: AsRef<str>,
    C: AsRef<str>, 
[src]

Insert a named string template.

pub fn add<P>(&mut self, name: String, file: P) -> Result<()> where
    P: AsRef<Path>, 
[src]

Add a named template from a file.

Requires the fs feature.

pub fn load<P: AsRef<Path>>(&mut self, file: P) -> Result<()>[src]

Load a file and use the file path as the template name.

Requires the fs feature.

pub fn read_dir<P: AsRef<Path>>(
    &mut self,
    file: P,
    extension: &str
) -> Result<()>
[src]

Load all the files in a target directory that match the given extension.

The generated name is the file stem; ie, the name of the file once the extension has been removed.

Requires the fs feature.

pub fn compile<'a, S>(
    &self,
    template: S,
    options: ParserOptions
) -> Result<Template> where
    S: AsRef<str>, 
[src]

Compile a string to a template.

To compile a template and add it to this registry use insert(), add(), load() or read_dir().

pub fn parse<'a, S>(&self, name: &str, template: S) -> Result<Template> where
    S: AsRef<str>, 
[src]

Compile a string to a template using the given name.

This is a convenience function for calling compile() using parser options with the given name.

pub fn lint<S>(&self, name: &str, template: S) -> Result<Vec<Error>> where
    S: AsRef<str>, 
[src]

Lint a template.

pub fn once<T, S>(&self, name: &str, source: S, data: &T) -> Result<String> where
    T: Serialize,
    S: AsRef<str>, 
[src]

Render a template without registering it and return the result as a string.

This function buffers the template nodes before rendering.

pub fn render<T>(&self, name: &str, data: &T) -> Result<String> where
    T: Serialize
[src]

Render a named template and buffer the result to a string.

The named template must exist in the templates collection.

pub fn render_template<'a, T>(
    &self,
    name: &str,
    template: &Template,
    data: &T
) -> Result<String> where
    T: Serialize
[src]

Render a compiled template without registering it and buffer the result to a string.

pub fn render_to_write<T>(
    &self,
    name: &str,
    data: &T,
    writer: &mut impl Output
) -> Result<()> where
    T: Serialize
[src]

Render a named template to a writer.

The named template must exist in the templates collection.

Auto Trait Implementations

impl<'reg> !RefUnwindSafe for Registry<'reg>

impl<'reg> Send for Registry<'reg>

impl<'reg> Sync for Registry<'reg>

impl<'reg> Unpin for Registry<'reg>

impl<'reg> !UnwindSafe for Registry<'reg>

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, 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.