Struct liquid::Context [] [src]

pub struct Context<'a> {
    pub filters: HashMap<StringBox<Fn(&str) -> String + 'a>>,
    // some fields omitted
}

Fields

filters: HashMap<StringBox<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<StringValue>) -> Context<'a>

fn with_filters(filters: HashMap<StringBox<Fn(&str) -> String + 'a>>) -> Context<'a>

fn with_values_and_filters(values: HashMap<StringValue>, filters: HashMap<StringBox<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));

Trait Implementations

impl<'a> Default for Context<'a>
[src]

fn default() -> Context<'a>

Returns the "default value" for a type. Read more