diff options
-rw-r--r-- | testing/templates/option.html | 5 | ||||
-rw-r--r-- | testing/tests/simple.rs | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/testing/templates/option.html b/testing/templates/option.html new file mode 100644 index 0000000..64a055e --- /dev/null +++ b/testing/templates/option.html @@ -0,0 +1,5 @@ +{% if var.is_some() -%} + some: {{ var.unwrap() }} +{%- else -%} + none +{%- endif %} diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 00acda5..8e5c85a 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -107,3 +107,18 @@ fn test_attr() { let t = AttrTemplate { inner: Holder { a: 5 } }; assert_eq!(t.render(), "5\n"); } + + +#[derive(Template)] +#[template(path = "option.html")] +struct OptionTemplate<'a> { + var: Option<&'a str>, +} + +#[test] +fn test_option() { + let some = OptionTemplate { var: Some("foo") }; + assert_eq!(some.render(), "some: foo\n"); + let none = OptionTemplate { var: None }; + assert_eq!(none.render(), "none\n"); +} |