Add test for variable declaration

This commit is contained in:
Dirkjan Ochtman 2017-08-16 12:51:11 +02:00
parent 05597b61da
commit d7ac0825e0
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,7 @@
{% let val -%}
{% if cond -%}
{% let val = "foo" -%}
{% else -%}
{% let val = s -%}
{% endif -%}
{{ val }}

View File

@ -14,3 +14,17 @@ 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");
}