pub struct Renderer { /* private fields */ }Expand description
A struct providing a simple interface to build and render templates.
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn new<O>(options: O, default: String) -> Selfwhere
O: Into<RenderOptions>,
pub fn new<O>(options: O, default: String) -> Selfwhere
O: Into<RenderOptions>,
Sourcepub fn init(&mut self) -> Result<()>
pub fn init(&mut self) -> Result<()>
Initializes Renderer by building Templates depending on whether a templates
directory is provided or not. If none is provided then the default template is built.
§Errors
Will return Err if:
- A template contains either syntax errors or contains variables that reference non-existent
fields in a
Book/Annotation. - A template’s config block isn’t formatted correctly, has syntax errors or is missing required fields.
- A requested template-group does not exist.
- Any IO errors are encountered.
Sourcepub fn render(&mut self, entry: &Entry) -> Result<()>
pub fn render(&mut self, entry: &Entry) -> Result<()>
Iterates through all Templates and renders them based on their StructureMode and
ContextMode. See respective enums for more information.
§Arguments
entry- The entry to be rendered.
§Errors
Will return Err if any IO errors are encountered.
Sourcepub fn templates_rendered(&self) -> impl Iterator<Item = &Render>
pub fn templates_rendered(&self) -> impl Iterator<Item = &Render>
Returns an iterator over all Renders.
Sourcepub fn templates_rendered_mut(&mut self) -> impl Iterator<Item = &mut Render>
pub fn templates_rendered_mut(&mut self) -> impl Iterator<Item = &mut Render>
Returns a mutable iterator over all Renders.
Sourcepub fn count_templates(&self) -> usize
pub fn count_templates(&self) -> usize
Returns the number of Templates.
Sourcepub fn count_templates_rendered(&self) -> usize
pub fn count_templates_rendered(&self) -> usize
Returns the number of Renders.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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