chain

Function chain 

Source
pub fn chain(
    _state: &State<'_, '_>,
    value: Value,
    others: Rest<Value>,
) -> Result<Value, Error>
Expand description

Chain two or more iterable objects as a single iterable object.

If all the individual objects are dictionaries, then the final chained object also acts like a dictionary – you can lookup a key, or iterate over the keys etc. Note that the dictionaries are not merged, so if there are duplicate keys, then the lookup will return the value from the last matching dictionary in the chain.

If all the individual objects are sequences, then the final chained object also acts like a list as if the lists are appended.

Otherwise, the chained object acts like an iterator chaining individual iterators, but it cannot be indexed.

{{ users | chain(moreusers) | length }}
{% for user, info in shard0 | chain(shard1, shard2) | dictsort %}
  {{user}}: {{info}}
{% endfor %}
{{ list1 | chain(list2) | attr(1) }}