[][src]Struct text_placeholder::Template

pub struct Template<'t> { /* fields omitted */ }

A template is composed of tokens, which in turn can represent plain text or a named placeholder.

Implementations

impl<'t> Template<'t>[src]

pub fn new(text: &'t str) -> Self[src]

Generates a Template with boundaries specified by the handlebars syntax, this means that within the string "hello {{key}}" we will have key as a named placeholder.

pub fn new_with_placeholder(text: &'t str, start: &'t str, end: &'t str) -> Self[src]

Generates a Template with boundaries specified by the start and end arguments. Example:

Template::new_with_placeholder("Hello [key]!", "[", "]");

pub fn fill_with_hashmap(&self, replacements: &HashMap<&str, &str>) -> String[src]

Fill the template's placeholders using the provided replacements HashMap in order to to infer values for the named placeholders.

Placeholders without an associated value will be replaced with an empty string.

For a version that generates an error in case a placeholder is missing see fill_with_hashmap_strict.

pub fn fill_with_hashmap_strict(
    &self,
    replacements: &HashMap<&str, &str>
) -> Result<String, Error>
[src]

Fill the template's placeholders using the provided replacements HashMap in order to to infer values for the named placeholders.

Placeholders without an associated value will result in a Error::PlaceholderError.

For a version that does not generate an error in case a placeholder is missing see fill_with_hashmap.

Auto Trait Implementations

impl<'t> RefUnwindSafe for Template<'t>

impl<'t> Send for Template<'t>

impl<'t> Sync for Template<'t>

impl<'t> Unpin for Template<'t>

impl<'t> UnwindSafe for Template<'t>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.