pub struct Parser { /* fields omitted */ }
Parses a liquid template, returning a Template object.
let template = liquid::ParserBuilder::with_liquid()
.build().unwrap()
.parse("Liquid!").unwrap();
let globals = liquid::value::Object::new();
let output = template.render(&globals).unwrap();
assert_eq!(output, "Liquid!".to_string());
Parse a liquid template from a file, returning a Result<Template, Error>
.
template.txt
:
"Liquid {{data}}"
Your rust code:
let template = liquid::ParserBuilder::with_liquid()
.build().unwrap()
.parse_file("path/to/template.txt").unwrap();
let mut globals = liquid::value::Object::new();
globals.insert("data".into(), liquid::value::Value::scalar(4f64));
let output = template.render(&globals).unwrap();
assert_eq!(output, "Liquid! 4\n".to_string());
Returns the "default value" for a type. Read more
Performs copy-assignment from source
. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Any for T where T: Any, | |
impl<T> CloneAny for T where T: Clone + Any, | |