diff options
Diffstat (limited to '')
-rw-r--r-- | testing/templates/hello.html | 1 | ||||
-rw-r--r-- | testing/tests/hello.rs | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/testing/templates/hello.html b/testing/templates/hello.html new file mode 100644 index 0000000..8149be7 --- /dev/null +++ b/testing/templates/hello.html @@ -0,0 +1 @@ +Hello, {{ name }}! 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. +} |