diff options
Diffstat (limited to 'testing/tests')
-rw-r--r-- | testing/tests/hello.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/tests/hello.rs b/testing/tests/hello.rs new file mode 100644 index 0000000..12ffde6 --- /dev/null +++ b/testing/tests/hello.rs @@ -0,0 +1,18 @@ +#[macro_use] +extern crate askama; + +use askama::Template; + +#[derive(Template)] // this will generate the code... +#[template(path = "hello.html", print = "all")] // using the template in this path, relative + // to the templates dir in the crate root +struct HelloTemplate<'a> { // the name of the struct can be anything + name: &'a str, // the field name should match the variable name + // in your template +} + +#[test] +fn main() { + let hello = HelloTemplate { name: "world" }; // instantiate your struct + assert_eq!("Hello, world!", hello.render().unwrap()); // then render it. +} |