Function gtmpl::funcs::index [] [src]

pub fn index(args: &[Arc<Any>]) -> Result<Arc<Any>, String>

Returns the result of indexing its first argument by the following arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each indexed item must be a map, slice or array.

Example

use gtmpl::template;
let ctx = vec![23, 42, 7];
let index = template("{{ index . 1 }}", ctx);
assert_eq!(&index.unwrap(), "42");