diff options
Diffstat (limited to '')
-rw-r--r-- | askama/src/lib.rs | 9 | ||||
-rw-r--r-- | askama_derive/src/generator.rs | 2 | ||||
-rw-r--r-- | testing/tests/simple.rs | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/askama/src/lib.rs b/askama/src/lib.rs index 0c0ff83..187b571 100644 --- a/askama/src/lib.rs +++ b/askama/src/lib.rs @@ -395,8 +395,13 @@ pub trait Template { } /// Renders the template to the given `writer` buffer fn render_into(&self, writer: &mut std::fmt::Write) -> Result<()>; - /// Helper method to inspect the template's extension - fn extension(&self) -> Option<&str>; + /// Helper function to inspect the template's extension + fn extension() -> Option<&'static str> + where + Self: Sized, + { + None + } } pub use askama_derive::*; diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 2c9fddb..4f83b07 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -107,7 +107,7 @@ impl<'a> Generator<'a> { buf.writeln("Ok(())"); buf.writeln("}"); - buf.writeln("fn extension(&self) -> Option<&str> {"); + buf.writeln("fn extension() -> Option<&'static str> {"); buf.writeln(&format!( "{:?}", self.input.path.extension().map(|s| s.to_str().unwrap()) diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 9575daa..e19b32e 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -27,7 +27,7 @@ fn test_variables() { Iñtërnâtiônàlizætiøn is important\n\ in vars too: Iñtërnâtiônàlizætiøn" ); - assert_eq!(s.extension(), Some("html")); + assert_eq!(VariablesTemplate::extension(), Some("html")); } #[derive(Template)] |