diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 12:37:01 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-08-10 12:37:01 +0200 |
commit | e8c47b7135a1ecf3414c6495b1cb592ae3e2d8a3 (patch) | |
tree | 1a8a08968d7f169e145a4767726177f7322b5ed8 /testing/tests/hello.rs | |
parent | adfc52a26d3da8f62fad81eb1b12ffc7202583e7 (diff) | |
download | askama-e8c47b7135a1ecf3414c6495b1cb592ae3e2d8a3.tar.gz askama-e8c47b7135a1ecf3414c6495b1cb592ae3e2d8a3.tar.bz2 askama-e8c47b7135a1ecf3414c6495b1cb592ae3e2d8a3.zip |
Add README example as a test case
Diffstat (limited to 'testing/tests/hello.rs')
-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. +} |