From df58dcb49db77b2c283db3c9a8a738bdff3a8e37 Mon Sep 17 00:00:00 2001 From: larros Date: Tue, 26 Sep 2017 10:02:44 +0200 Subject: Add support for importing template files with macros (#51) * Fix review comments for macro imports --- testing/templates/import.html | 2 ++ testing/tests/macro.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 testing/templates/import.html (limited to 'testing') diff --git a/testing/templates/import.html b/testing/templates/import.html new file mode 100644 index 0000000..87d7969 --- /dev/null +++ b/testing/templates/import.html @@ -0,0 +1,2 @@ +{% import "macro.html" -%} +{%- call thrice(s) %} diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs index 72f578e..25d95d8 100644 --- a/testing/tests/macro.rs +++ b/testing/tests/macro.rs @@ -14,3 +14,15 @@ fn test_macro() { let t = MacroTemplate { s: "foo" }; assert_eq!(t.render().unwrap(), "foo foo foo"); } + +#[derive(Template)] +#[template(path = "import.html")] +struct ImportTemplate<'a> { + s: &'a str, +} + +#[test] +fn test_import() { + let t = ImportTemplate { s: "foo" }; + assert_eq!(t.render().unwrap(), "foo foo foo"); +} -- cgit