minijinja::functions

Function range

Source
pub fn range(
    lower: u32,
    upper: Option<u32>,
    step: Option<u32>,
) -> Result<Value, Error>
Expand description

Returns a range.

Return a list containing an arithmetic progression of integers. range(i, j) returns [i, i+1, i+2, ..., j-1]. lower defaults to 0. When step is given, it specifies the increment (or decrement). For example, range(4) and range(0, 4, 1) return [0, 1, 2, 3]. The end point is omitted.

<ul>
{% for num in range(1, 11) %}
  <li>{{ num }}
{% endfor %}
</ul>

This function will refuse to create ranges over 10.000 items.