Struct minimad::OwningTemplateExpander
source · pub struct OwningTemplateExpander<'s> { /* private fields */ }
Expand description
A template expander owning the value you set so that you don’t have to keep them around until you produce the text to display. Additionnaly, the same expander can be used for several templates.
Implementations§
source§impl<'s> OwningTemplateExpander<'s>
impl<'s> OwningTemplateExpander<'s>
pub fn new() -> Self
sourcepub fn set_default<S: Into<String>>(&mut self, value: S) -> &mut Self
pub fn set_default<S: Into<String>>(&mut self, value: S) -> &mut Self
set a default value to use when no replacement was defined.
When you don’t call this method, the expanded text contains the
original names like ${my_arg_name}
(which is useful when developing
your filling code)
sourcepub fn set<S: Display>(&mut self, name: &'s str, value: S) -> &mut Self
pub fn set<S: Display>(&mut self, name: &'s str, value: S) -> &mut Self
replace placeholders with name name
with the given value, non interpreted
(i.e. stars, backquotes, etc. don’t mess the styling defined by the template)
sourcepub fn set_md<S: Into<String>>(&mut self, name: &'s str, value: S) -> &mut Self
pub fn set_md<S: Into<String>>(&mut self, name: &'s str, value: S) -> &mut Self
replace placeholders with name name
with the given value, interpreted as markdown
sourcepub fn sub(&mut self, name: &'s str) -> &mut OwningSubTemplateExpander<'s>
pub fn sub(&mut self, name: &'s str) -> &mut OwningSubTemplateExpander<'s>
return a sub template expander. You can do set and set_md on the returned sub to fill an instance of the repeation section.
sourcepub fn set_lines<S: Into<String>>(
&mut self,
name: &'s str,
raw_lines: S
) -> &mut Self
pub fn set_lines<S: Into<String>>( &mut self, name: &'s str, raw_lines: S ) -> &mut Self
replace a placeholder with several lines. This is mostly useful when the placeholder is a repeatable line (code, list item)
sourcepub fn set_lines_md<S: Into<String>>(
&mut self,
name: &'s str,
md: S
) -> &mut Self
pub fn set_lines_md<S: Into<String>>( &mut self, name: &'s str, md: S ) -> &mut Self
replace a placeholder with several lines interpreted as markdown
sourcepub fn expand<'t>(&'s self, template: &'t TextTemplate<'s>) -> Text<'s>
pub fn expand<'t>(&'s self, template: &'t TextTemplate<'s>) -> Text<'s>
build a text by applying the replacements to the initial template