[−][src]Struct requestr_core::Template
Fields
src: String
matches: Vec<(usize, usize)>
names: HashSet<String>
Implementations
impl Template
[src]
pub fn new(template: &str) -> Self
[src]
pub fn render(&self, vals: &HashMap<String, String>) -> String
[src]
Examples
use std::collections::HashMap; use requestr_core::Template; let template = Template::new("Hi, my name is {{ name }} and I'm a {{ lang }} developer."); let mut args: HashMap<String, String> = HashMap::new(); args.insert("name".to_string(), "Stefan".to_string()); args.insert("lang".to_string(), "Scala".to_string()); let s = template.render(&args); assert_eq!(s, "Hi, my name is Stefan and I'm a Scala developer.");
use std::collections::HashMap; use requestr_core::Template; let template = Template::new("Hi, my name is {{ name }} and I'm a {{lang}} developer."); let mut args: HashMap<String, String> = HashMap::new(); args.insert("name".to_string(), "undefined".to_string()); args.insert("lang".to_string(), "JavaScript".to_string()); let s = template.render(&args); assert_eq!(s, "Hi, my name is undefined and I'm a JavaScript developer.");
Trait Implementations
impl Debug for Template
[src]
impl PartialEq<Template> for Template
[src]
impl StructuralPartialEq for Template
[src]
Auto Trait Implementations
impl RefUnwindSafe for Template
[src]
impl Send for Template
[src]
impl Sync for Template
[src]
impl Unpin for Template
[src]
impl UnwindSafe for Template
[src]
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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.
pub 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>,