aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/loop_else.rs
blob: 99dfc4b8654e9c191c8c49ae0e6077f05cd4033e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use askama::Template;

#[derive(Template)]
#[template(
    source = "{% for v in values %}{{ v }}{% else %}empty{% endfor %}",
    ext = "txt"
)]
struct ForElse<'a> {
    values: &'a [i32],
}

#[test]
fn test_for_else() {
    let t = ForElse { values: &[1, 2, 3] };
    assert_eq!(t.render().unwrap(), "123");

    let t = ForElse { values: &[] };
    assert_eq!(t.render().unwrap(), "empty");
}