pub struct TemplateManager {
pub tera: Tera,
pub definitions: HashMap<String, TemplateDefinition>,
/* private fields */
}Expand description
Provides a common Api for the three layout types and output formats.
Fields§
§tera: Tera§definitions: HashMap<String, TemplateDefinition>Implementations§
Source§impl TemplateManager
impl TemplateManager
Sourcepub fn from_path(
template_path: PathBuf,
filter_path: PathBuf,
create_filters: bool,
) -> Result<Self>
pub fn from_path( template_path: PathBuf, filter_path: PathBuf, create_filters: bool, ) -> Result<Self>
Create new template manager from template path. Reads the template files.
Sourcepub fn register_filter<F: Filter + 'static>(&mut self, name: &str, filter: F)
pub fn register_filter<F: Filter + 'static>(&mut self, name: &str, filter: F)
Register Tera filter
Sourcepub fn get_template(
&self,
id: &str,
type_: TemplateType,
) -> Result<TemplateDefinition>
pub fn get_template( &self, id: &str, type_: TemplateType, ) -> Result<TemplateDefinition>
Fetch a TemplateDefinition by specifying its id and type.
Sourcepub fn render(
&self,
id: &str,
template_prefix: &str,
type_: TemplateType,
args: &Context,
buf: impl Write,
) -> Result<()>
pub fn render( &self, id: &str, template_prefix: &str, type_: TemplateType, args: &Context, buf: impl Write, ) -> Result<()>
Render a template to a specified format
§Arguments
id- The template identifier (the name of the definition file)template_prefix- The template format key (which output format to use)type_- The kind of template to render (builtin/layout/shortcode). Ensures that different types can have templates with the same id.args- Template arguments contained in a Tera context.buf- Buffer to write the output to.
Sourcepub fn validate_args_for_template(
&self,
id: &str,
args: &[RenderedParam],
) -> Result<Vec<Result<()>>>
pub fn validate_args_for_template( &self, id: &str, args: &[RenderedParam], ) -> Result<Vec<Result<()>>>
Performs argument validation for shortcodes.
Trait Implementations§
Source§impl Clone for TemplateManager
impl Clone for TemplateManager
Source§fn clone(&self) -> TemplateManager
fn clone(&self) -> TemplateManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TemplateManager
impl !RefUnwindSafe for TemplateManager
impl Send for TemplateManager
impl Sync for TemplateManager
impl Unpin for TemplateManager
impl !UnwindSafe for TemplateManager
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, R> RenderElement<Vec<R>> for Twhere
T: RenderElement<R>,
impl<T, R> RenderElement<Vec<R>> for Twhere
T: RenderElement<R>,
Source§fn render(
&mut self,
elem: &Vec<R>,
ctx: &RenderContext<'_>,
buf: impl Write,
) -> Result<(), Error>
fn render( &mut self, elem: &Vec<R>, ctx: &RenderContext<'_>, buf: impl Write, ) -> Result<(), Error>
Render the element to a buffer
Source§fn render_inner(&mut self, elem: &T, ctx: &RenderContext<'_>) -> Result<CowStr>
fn render_inner(&mut self, elem: &T, ctx: &RenderContext<'_>) -> Result<CowStr>
Convenience function for creating a buffer, rendering the element into the buffer, and
returning the result as a string. This is useful when an inner element needs to be rendered
first to be used in an outer element, hence the name.
Source§impl<T> Variant for T
impl<T> Variant for T
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert this
Variant trait object to &mut dyn Any.Source§fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
fn as_boxed_any(self: Box<T>) -> Box<dyn Any>
Convert this
Variant trait object to Box<dyn Any>.