Struct minimad::TextTemplateExpander
source · [−]pub struct TextTemplateExpander<'s, 'b> { /* private fields */ }
Expand description
an expander you get from a template. You specify replacements
on the expander then you ask it the text using expand
Implementations
sourceimpl<'s, 'b> TextTemplateExpander<'s, 'b>
impl<'s, 'b> TextTemplateExpander<'s, 'b>
sourcepub fn set(
&mut self,
name: &str,
value: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
pub fn set(
&mut self,
name: &str,
value: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
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_all(&mut self, value: &'s str) -> &mut TextTemplateExpander<'s, 'b>
pub fn set_all(&mut self, value: &'s str) -> &mut TextTemplateExpander<'s, 'b>
replace all placeholders with the given value, non interpreted (i.e. stars, backquotes, etc. don’t mess the styling defined by the template). This can be used at start to have a “default” value.
sourcepub fn set_md(
&mut self,
name: &'b str,
value: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
pub fn set_md(
&mut self,
name: &'b str,
value: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
replace placeholders with name name
with the given value, interpreted as markdown
sourcepub fn set_lines(
&mut self,
name: &'b str,
raw_lines: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
pub fn set_lines(
&mut self,
name: &'b str,
raw_lines: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
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(
&mut self,
name: &'b str,
md: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
pub fn set_lines_md(
&mut self,
name: &'b str,
md: &'s str
) -> &mut TextTemplateExpander<'s, 'b>
replace a placeholder with several lines interpreted as markdown
sourcepub fn sub(&mut self, name: &'b str) -> &mut SubTemplateExpander<'s, 'b>
pub fn sub(&mut self, name: &'b str) -> &mut SubTemplateExpander<'s, 'b>
prepare expansion of a sub template and return a mutable reference to the object in which to set compound replacements
Trait Implementations
sourceimpl<'s, 'b> From<&'b TextTemplate<'s>> for TextTemplateExpander<'s, 'b>
impl<'s, 'b> From<&'b TextTemplate<'s>> for TextTemplateExpander<'s, 'b>
sourcefn from(template: &'b TextTemplate<'s>) -> Self
fn from(template: &'b TextTemplate<'s>) -> Self
Build a new expander for the template. The expander stores the additions
done with set
, set_md
, set_lines
or in the sub
expanders.