mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
Add test case for matching on Option<bool>
This commit is contained in:
parent
35cf03cf79
commit
ed2e640dbd
8
testing/templates/match-opt-bool.html
Normal file
8
testing/templates/match-opt-bool.html
Normal file
@ -0,0 +1,8 @@
|
||||
{% match item %}
|
||||
{% when Some with (true) %}
|
||||
Found Some(true)
|
||||
{% when Some with (false) %}
|
||||
Found Some(false)
|
||||
{% when None %}
|
||||
Not Found
|
||||
{% endmatch %}
|
@ -26,6 +26,24 @@ fn test_match_option() {
|
||||
assert_eq!(s.render().unwrap(), "\nNot Found\n");
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "match-opt-bool.html")]
|
||||
struct MatchOptBoolTemplate {
|
||||
item: Option<bool>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_option_bool() {
|
||||
let s = MatchOptBoolTemplate { item: Some(true) };
|
||||
assert_eq!(s.render().unwrap(), "\nFound Some(true)\n");
|
||||
|
||||
let s = MatchOptBoolTemplate { item: Some(false) };
|
||||
assert_eq!(s.render().unwrap(), "\nFound Some(false)\n");
|
||||
|
||||
let s = MatchOptBoolTemplate { item: None };
|
||||
assert_eq!(s.render().unwrap(), "\nNot Found\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_ref_deref() {
|
||||
let s = MatchOptRefTemplate { item: &Some("foo") };
|
||||
|
Loading…
x
Reference in New Issue
Block a user