Struct liquid::Context
[−]
[src]
pub struct Context<'a> { pub filters: HashMap<String, Box<Fn(&str) -> String + 'a>>, // some fields omitted }
Fields
filters: HashMap<String, Box<Fn(&str) -> String + 'a>>
Methods
impl<'a> Context<'a>
[src]
fn new() -> Context<'a>
Creates a new, empty rendering context.
Examples
let mut ctx = Context::new(); assert_eq!(ctx.get_val("test"), None);
fn with_values(values: HashMap<String, Value>) -> Context<'a>
fn with_filters(filters: HashMap<String, Box<Fn(&str) -> String + 'a>>) -> Context<'a>
fn with_values_and_filters(values: HashMap<String, Value>, filters: HashMap<String, Box<Fn(&str) -> String + 'a>>) -> Context<'a>
fn get_val(&self, name: &str) -> Option<&Value>
Gets a value from the rendering context.
Examples
let mut ctx = Context::new(); ctx.set_val("test", Value::Num(42f32)); assert_eq!(ctx.get_val("test").unwrap(), &Value::Num(42f32));
fn set_val(&mut self, name: &str, val: Value) -> Option<Value>
Sets a value to the rendering context. Note that it needs to be wrapped in a liquid::Value.
Examples
let mut ctx = Context::new(); ctx.set_val("test", Value::Num(42f32)); assert_eq!(ctx.get_val("test").unwrap(), &Value::Num(42f32));