pub struct Rion<'template> { /* private fields */ }Expand description
The Rion struct is the entry point for the Rion library. It contains the template and formatter registries and provides functions to render templates as well as to register templates and formatters.
Implementations§
Source§impl<'template> Rion<'template>
impl<'template> Rion<'template>
Sourcepub fn new() -> Rion<'template>
pub fn new() -> Rion<'template>
Create a new Rion registry. The returned registry contains no templates, and has
format_unescaped registered as a formatter named “unescaped”.
Sourcepub fn resolve_var_str<C>(template: &str, context: &C) -> Result<String>where
C: Serialize,
pub fn resolve_var_str<C>(template: &str, context: &C) -> Result<String>where
C: Serialize,
Resolves variables with just context and template
Sourcepub fn resolve_var<C>(template: &str, context: &C) -> Result<Value>where
C: Serialize,
pub fn resolve_var<C>(template: &str, context: &C) -> Result<Value>where
C: Serialize,
Resolves variables with just context and template
Sourcepub fn resolve_varaibles<C>(&self, template: &str, context: &C) -> Result<Value>where
C: Serialize,
pub fn resolve_varaibles<C>(&self, template: &str, context: &C) -> Result<Value>where
C: Serialize,
Resolves variables with just context and template
Sourcepub fn resolve_varaibles_str<C>(
&self,
template: &str,
context: &C,
) -> Result<String>where
C: Serialize,
pub fn resolve_varaibles_str<C>(
&self,
template: &str,
context: &C,
) -> Result<String>where
C: Serialize,
Resolves variables with just context and template
Sourcepub fn add_template(
&mut self,
name: &'template str,
text: &'template str,
) -> Result<()>
pub fn add_template( &mut self, name: &'template str, text: &'template str, ) -> Result<()>
Parse and compile the given template, then register it under the given name.
Sourcepub fn set_default_formatter<F>(&mut self, formatter: &'template F)
pub fn set_default_formatter<F>(&mut self, formatter: &'template F)
Changes the default formatter from format to formatter. Usefull in combination with format_unescaped to deactivate HTML-escaping
Sourcepub fn add_formatter<F>(&mut self, name: &'template str, formatter: F)
pub fn add_formatter<F>(&mut self, name: &'template str, formatter: F)
Register the given formatter function under the given name.
Trait Implementations§
Auto Trait Implementations§
impl<'template> Freeze for Rion<'template>
impl<'template> !RefUnwindSafe for Rion<'template>
impl<'template> !Send for Rion<'template>
impl<'template> !Sync for Rion<'template>
impl<'template> Unpin for Rion<'template>
impl<'template> !UnwindSafe for Rion<'template>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more