#[macro_use]
extern crate askama;

use askama::Template;

#[derive(Template)]
#[template(source = "{{ self.get_s() }}", ext = "txt")]
struct SelfMethodTemplate<'a> {
    s: &'a str,
}

impl<'a> SelfMethodTemplate<'a> {
    fn get_s(&self) -> &str {
        self.s
    }
}

#[test]
fn test_self_method() {
    let t = SelfMethodTemplate { s: "foo" };
    assert_eq!(t.render().unwrap(), "foo");
}


#[derive(Template)]
#[template(source = "{{ self.get_s() }} {{ t.get_s() }}", ext = "txt")]
struct NestedSelfMethodTemplate<'a> {
    t: SelfMethodTemplate<'a>,
}

impl<'a> NestedSelfMethodTemplate<'a> {
    fn get_s(&self) -> &str {
        "bar"
    }
}

#[test]
fn test_nested() {
    let t = NestedSelfMethodTemplate {
        t: SelfMethodTemplate { s: "foo" },
    };
    assert_eq!(t.render().unwrap(), "bar foo");
}

#[macro_use]
extern crate askama;

use askama::Template;

#[derive(Template)]
#[template(source = "{{ self.get_s() }}", ext = "txt")]
struct MethodTemplate<'a> {
    s: &'a str,
}

impl<'a> MethodTemplate<'a> {
    fn get_s(&self) -> &str {
        self.s
    }
}

#[derive(Template)]
#[template(source = "{{ self.get_s() }} {{ t.get_s() }}", ext = "txt")]
struct NestedMethodTemplate<'a> {
    t: MethodTemplate<'a>,
}

impl<'a> NestedMethodTemplate<'a> {
    fn get_s(&self) -> &str {
        "bar"
    }
}

#[test]
fn test_method() {
    let t = MethodTemplate { s: "foo" };
    assert_eq!(t.render().unwrap(), "foo");
}

#[test]
fn test_nested() {
    let t = NestedMethodTemplate {
        t: MethodTemplate { s: "foo" },
    };
    assert_eq!(t.render().unwrap(), "bar foo");
}

--- 
+++ 
@@ -5,38 +5,39 @@
 
 #[derive(Template)]
 #[template(source = "{{ self.get_s() }}", ext = "txt")]
-struct MethodTemplate<'a> {
+struct SelfMethodTemplate<'a> {
     s: &'a str,
 }
 
-impl<'a> MethodTemplate<'a> {
+impl<'a> SelfMethodTemplate<'a> {
     fn get_s(&self) -> &str {
         self.s
     }
 }
 
+#[test]
+fn test_self_method() {
+    let t = SelfMethodTemplate { s: "foo" };
+    assert_eq!(t.render().unwrap(), "foo");
+}
+
+
 #[derive(Template)]
 #[template(source = "{{ self.get_s() }} {{ t.get_s() }}", ext = "txt")]
-struct NestedMethodTemplate<'a> {
-    t: MethodTemplate<'a>,
+struct NestedSelfMethodTemplate<'a> {
+    t: SelfMethodTemplate<'a>,
 }
 
-impl<'a> NestedMethodTemplate<'a> {
+impl<'a> NestedSelfMethodTemplate<'a> {
     fn get_s(&self) -> &str {
         "bar"
     }
 }
 
 #[test]
-fn test_method() {
-    let t = MethodTemplate { s: "foo" };
-    assert_eq!(t.render().unwrap(), "foo");
-}
-
-#[test]
 fn test_nested() {
-    let t = NestedMethodTemplate {
-        t: MethodTemplate { s: "foo" },
+    let t = NestedSelfMethodTemplate {
+        t: SelfMethodTemplate { s: "foo" },
     };
     assert_eq!(t.render().unwrap(), "bar foo");
 }
Reformat and rename method testing tests for better organization
