aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_derive/src/generator.rs6
-rw-r--r--testing/tests/simple.rs12
2 files changed, 16 insertions, 2 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 0395c11..e0c0efb 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -137,7 +137,7 @@ impl<'a> Generator<'a> {
fn impl_display(&mut self, buf: &mut Buffer) {
self.write_header(buf, "::std::fmt::Display", None);
buf.writeln("fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {");
- buf.writeln("self.render_into(f).map_err(|_| ::std::fmt::Error {})");
+ buf.writeln("::askama::Template::render_into(self, f).map_err(|_| ::std::fmt::Error {})");
buf.writeln("}");
buf.writeln("}");
}
@@ -150,7 +150,9 @@ impl<'a> Generator<'a> {
None,
);
buf.writeln("fn modify(self, res: &mut ::askama::iron::Response) {");
- buf.writeln("res.body = Some(Box::new(self.render().unwrap().into_bytes()));");
+ buf.writeln(
+ "res.body = Some(Box::new(::askama::Template::render(&self).unwrap().into_bytes()));",
+ );
let ext = self
.input
diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs
index d4d2964..2bf8e7a 100644
--- a/testing/tests/simple.rs
+++ b/testing/tests/simple.rs
@@ -289,3 +289,15 @@ struct Empty;
fn test_empty() {
assert_eq!(Empty.render().unwrap(), "foo");
}
+
+mod without_import_on_derive {
+ #[derive(askama::Template)]
+ #[template(source = "foo", ext = "txt")]
+ struct WithoutImport;
+
+ #[test]
+ fn test_without_import() {
+ use askama::Template;
+ assert_eq!(WithoutImport.render().unwrap(), "foo");
+ }
+}