Struct TemplateNest

Source
pub struct TemplateNest<'a> {
    pub delimiters: (&'a str, &'a str),
    pub label: &'a str,
    pub extension: &'a str,
    pub directory: PathBuf,
    pub show_labels: bool,
    pub comment_delimiters: (&'a str, &'a str),
    pub fixed_indent: bool,
    pub die_on_bad_params: bool,
    pub token_escape_char: &'a str,
    pub defaults: HashMap<String, Filling>,
}
Expand description

Renders a template hash to produce an output.

Fields§

§delimiters: (&'a str, &'a str)

Delimiters used in the template. It is a tuple of two strings, representing the start and end delimiters.

§label: &'a str

Name label used to identify the template to be used.

§extension: &'a str

Template extension, appended on label to identify the template.

§directory: PathBuf

Directory where templates are located.

§show_labels: bool

Prepend & Append a string to every template which is helpful in identifying which template the output text came from.

§comment_delimiters: (&'a str, &'a str)

Used in conjunction with show_labels. If the template is HTML then use ‘’.

§fixed_indent: bool

Intended to improve readability when inspecting nested templates.

§die_on_bad_params: bool

If True, then an attempt to populate a template with a variable that doesn’t exist (i.e. name not found in template file) results in an error.

§token_escape_char: &'a str

Escapes a token delimiter, i.e. if set to ’' then prefixing the token delimiters with ’' means it won’t be considered a variable.

=> is a variable

<!–% token %–> => is not a variable. (’' is removed from output)

§defaults: HashMap<String, Filling>

Provide a hash of default values that are substituted if template hash does not provide a value.

Implementations§

Source§

impl TemplateNest<'_>

Source

pub fn new(directory_str: &str) -> Result<Self, TemplateNestError>

Creates a new instance of TemplateNest with the specified directory.

Source

pub fn render(&self, filling: &Filling) -> Result<String, TemplateNestError>

Given a TemplateHash, it parses the TemplateHash and renders a String output.

Trait Implementations§

Source§

impl Default for TemplateNest<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TemplateNest<'a>

§

impl<'a> RefUnwindSafe for TemplateNest<'a>

§

impl<'a> Send for TemplateNest<'a>

§

impl<'a> Sync for TemplateNest<'a>

§

impl<'a> Unpin for TemplateNest<'a>

§

impl<'a> UnwindSafe for TemplateNest<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.