macro_rules! context {
($($key:ident => $value:expr),* $(,)?) => { ... };
}Expand description
Build a HashMap<String, Value> context from key => value pairs.
The map can be passed directly to Engine::render. For nested objects,
wrap an inner context! call in Value::from.
use gracile_core::{Engine, Value, context};
let ctx = context! {
name => "Alice",
score => 42,
active => true,
};
let out = Engine::new().render("{= name}: {= score}", ctx).unwrap();
assert_eq!(out, "Alice: 42");Nested example:
use gracile_core::{Value, context};
let ctx = context! {
user => Value::from(context! { name => "Alice", age => 30 }),
};