[−][src]Struct text_placeholder::Template
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
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]
&self,
replacements: &HashMap<&str, &str>
) -> Result<String, Error>
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,