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 strName label used to identify the template to be used.
extension: &'a strTemplate extension, appended on label to identify the template.
directory: PathBufDirectory where templates are located.
show_labels: boolPrepend & 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: boolIntended to improve readability when inspecting nested templates.
die_on_bad_params: boolIf 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 strEscapes 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<'_>
impl TemplateNest<'_>
Sourcepub fn new(directory_str: &str) -> Result<Self, TemplateNestError>
pub fn new(directory_str: &str) -> Result<Self, TemplateNestError>
Creates a new instance of TemplateNest with the specified directory.