mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-30 06:21:13 +00:00
Add test for variable declaration
This commit is contained in:
parent
05597b61da
commit
d7ac0825e0
7
testing/templates/let-decl.html
Normal file
7
testing/templates/let-decl.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% let val -%}
|
||||||
|
{% if cond -%}
|
||||||
|
{% let val = "foo" -%}
|
||||||
|
{% else -%}
|
||||||
|
{% let val = s -%}
|
||||||
|
{% endif -%}
|
||||||
|
{{ val }}
|
@ -14,3 +14,17 @@ fn test_let() {
|
|||||||
let t = LetTemplate { s: "foo" };
|
let t = LetTemplate { s: "foo" };
|
||||||
assert_eq!(t.render().unwrap(), "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");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user