diff options
| author | 2021-01-11 19:48:37 +0100 | |
|---|---|---|
| committer | 2021-01-13 08:58:49 +0100 | |
| commit | 000aff4a18c90a5074afd1af5587ff94e915e7d1 (patch) | |
| tree | 546f052b67b0607d6dd17611665a59e28783158a /testing/tests | |
| parent | 912bbeb395f183b67eb9500687e865ef24ff62ae (diff) | |
| download | askama-000aff4a18c90a5074afd1af5587ff94e915e7d1.tar.gz askama-000aff4a18c90a5074afd1af5587ff94e915e7d1.tar.bz2 askama-000aff4a18c90a5074afd1af5587ff94e915e7d1.zip | |
Added constants test
Diffstat (limited to '')
| -rw-r--r-- | testing/tests/simple.rs | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 0c6b17e..e7fca2c 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -73,6 +73,36 @@ fn test_variables_no_escape() {  }  #[derive(Template)] +#[template( +    source = "{{ foo }} {{ foo_bar }} {{ FOO }} {{ FOO_BAR }} {{ self::FOO }} {{ self::FOO_BAR }} {{ Self::BAR }} {{ Self::BAR_BAZ }}", +    ext = "txt" +)] +struct ConstTemplate { +    foo: &'static str, +    foo_bar: &'static str, +} + +impl ConstTemplate { +    const BAR: &'static str = "BAR"; +    const BAR_BAZ: &'static str = "BAR BAZ"; +} + +#[test] +fn test_constants() { +    let t = ConstTemplate { +        foo: "foo", +        foo_bar: "foo bar", +    }; +    assert_eq!( +        t.render().unwrap(), +        "foo foo bar FOO FOO BAR FOO FOO BAR BAR BAR BAZ" +    ); +} + +const FOO: &str = "FOO"; +const FOO_BAR: &str = "FOO BAR"; + +#[derive(Template)]  #[template(path = "if.html")]  struct IfTemplate {      cond: bool, | 
