aboutsummaryrefslogblamecommitdiffstats
path: root/testing/tests/vars.rs
blob: 87af3f61409cef0f424863b51e6ffa1e59acce9e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13


                     
                                                           








                                           
 








                                   



                             

                                           
use askama::Template;

#[derive(Template)]
#[template(source = "{% let v = s %}{{ v }}", ext = "txt")]
struct LetTemplate<'a> {
    s: &'a str,
}

#[test]
fn test_let() {
    let t = LetTemplate { s: "foo" };
    assert_eq!(t.render().unwrap(), "foo");
}

#[derive(Template)]
#[template(path = "let-decl.html")]
struct LetDeclTemplate<'a> {
    cond: bool,
    s: &'a str,
}

#[test]
fn test_let_decl() {
    let t = LetDeclTemplate {
        cond: false,
        s: "bar",
    };
    assert_eq!(t.render().unwrap(), "bar");
}