tera 2.0.0-alpha.3

A template engine for Rust based on Jinja2/Django
Documentation
// literals + basic types
{{ -1 }}
{{ 1 }}
{{ 'hello' }}
{{ true }}
{{ -1.2 }}
{{ 1.2 }}
{{ a }}
{{ -a }}
{{ - a * 2 }}
{{ - (a * 2) }}
{{ [1, 1.2, a, 'b', true] }}
{{ [1, 1.2, a, 'b', true,] }}
{{ [[1], [2], [c, d]] }}
{{ hello.data[var].hey }}
{{ 1 + 2 + 3 }}
{{ 1 + count }}
{{ 1 + 2 * 3 }}
{{ a + b * c * d + e }}

// https://github.com/pallets/jinja/issues/119
{{ 2 * 4 % 8 }}
{{ [1 + 1, 2, 3 * 2,] }}

// string concat
{{ hey ~ ho }}
{{ 1 ~ ho }}
{{ -1.2 ~ ho }}
{{ [] ~ ho }}
{{ 'hey' ~ ho }}
{{ `hello` ~ ident ~ 'ho' }}

// Comparisons
{{ a == b }}
{{ a != b }}
{{ a <= b }}
{{ a >= b }}
{{ a < b }}
{{ a > b }}
{{ 1 + a > b }}
{{ 1 + a > b * 8 }}

// and/or
{{ a and b }}
{{ a or b }}
{{ a + 1 == 2 or b * 3 > 10 }}

// in
{{ a in b }}
{{ a in range(end=2) }}
{{ a in 'hello' }}
{{ a in b and b in c }}

// https://github.com/mozilla/nunjucks/pull/336
{{ msg.status in ['pending', 'confirmed'] and msg.body }}

// test
{{ a is defined }}
{{ a is not defined }}
{{ a + 1 is odd }}
{{ a + 1 is not odd }}
{{ a is ending_with(pat='s') }}

// function calls
{{ get_url(path=page.path, in_content=true) }}
{{ get_url() }}

// filters
{{ a | round }}
{{ a | round() }}
{{ 1 + 2.1 | round }}
{{ [1] + [3, 2] | sort }}
{{ (1 + 2.1) | round }}
{{ ([1, 2, 3] | length) + 1 }}
{{ value | json_encode | safe }}
{{ value | truncate(length=10) }}
{{ get_content() | upper | safe }}
{{ admin | default or user == current_user }}
{{ user == current_user or admin | default }}
{{ members in interfaces | groupby(attribute='vlan') }}
{{ a ~ b | upper }}
{{ status == 'needs_restart' | ternary(truthy='restart', falsy='continue') }}
{{ (status == 'needs_restart') | ternary(truthy='restart', falsy='continue') }}
{{ "one\ntwo\nthree" | indent }}

// Parentheses
{{ ((1)) }}
{{ (2 * 3) / 10 }}
{{ (2 + 1 + (a * 10 / (c + 1))) > 10 }}

// not
{{ not a }}
{{ not b * 1 }}
{{ not a and 1 + b > 3 }}
{{ not id and not true and not 1 + c }}
{{ a not in b }}
{{ not admin | default(val=true) }}
{{ a is containing(pat='a') and b is not containing(pat='b') }}
{{ a is containing(pat='a') and not b is containing(pat='b') }}

// Things not working in Tera v1
// https://github.com/Keats/tera/issues/478
{{ a > b and a > c }}
{{ (a > b) and (a > c) }}
{{ (person in groupA) and person in groupB }}
{{ (query.tags ~ ' ' ~ tags) | trim }}
{{ a and a is containing(pat='a') or b and b is containing(pat='b') }}
{{ ['up', 'down', 'left', 'right'][1] }}
{{ {"hello": "world"}["hello"] }}
{{ {"hel\nlo": "world"} }}

// Component calls
{{ <input label="Name" type="text"/> }}
{{ <input/> | safe }}
{{ <input n={a -1}/> }}

// null
{{ <input label={none}/> }}
{{ a == None }}