mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 15:25:19 +00:00
Added constants test
This commit is contained in:
parent
912bbeb395
commit
000aff4a18
@ -72,6 +72,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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user