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>

source

pub fn new() -> Self

source

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)

source

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)

source

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

source

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.

source

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)

source

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

source

pub fn expand<'t>(&'s self, template: &'t TextTemplate<'s>) -> Text<'s>

build a text by applying the replacements to the initial template

Trait Implementations§

source§

impl<'s> Default for OwningTemplateExpander<'s>

source§

fn default() -> OwningTemplateExpander<'s>

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.