[−][src]Struct bracket::registry::Registry
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 templates_mut(&mut self) -> &mut Templates
[src]
Mutable reference to the templates.
pub fn get_template(&self, name: &str) -> Option<&Template>
[src]
Use get() instead.
Get a named template.
pub fn get<S>(&self, name: S) -> Option<&Template> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Get a named template.
pub fn remove<S>(&mut self, name: S) -> Option<Template> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Remove a named template.
pub fn insert<N, C>(&mut self, name: N, content: C) -> Result<()> where
N: AsRef<str>,
C: AsRef<str>,
[src]
N: AsRef<str>,
C: AsRef<str>,
Insert a named string template.
pub fn add<P>(&mut self, name: String, file: P) -> Result<()> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
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]
&mut self,
file: P,
extension: &str
) -> Result<()>
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]
&self,
template: S,
options: ParserOptions
) -> Result<Template> where
S: AsRef<str>,
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]
S: AsRef<str>,
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]
S: AsRef<str>,
Lint a template.
pub fn once<T, S>(&self, name: &str, source: S, data: &T) -> Result<String> where
T: Serialize,
S: AsRef<str>,
[src]
T: Serialize,
S: AsRef<str>,
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]
T: Serialize,
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]
&self,
name: &str,
template: &Template,
data: &T
) -> Result<String> where
T: Serialize,
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]
&self,
name: &str,
data: &T,
writer: &mut impl Output
) -> Result<()> where
T: Serialize,
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>
[src]
impl<'reg> Send for Registry<'reg>
[src]
impl<'reg> Sync for Registry<'reg>
[src]
impl<'reg> Unpin for Registry<'reg>
[src]
impl<'reg> !UnwindSafe for Registry<'reg>
[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, 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>,