From 152c4e025f5dd21194e5c80da49fd6ca46718dde Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Fri, 14 May 2010 10:11:45 -0700 Subject: [PATCH] Contexts still can't see outer scope. Add failing test. --- examples/nested_context.mustache | 2 +- examples/nested_context.py | 3 +++ tests/test_examples.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/nested_context.mustache b/examples/nested_context.mustache index 0cf2418..b2f02a2 100644 --- a/examples/nested_context.mustache +++ b/examples/nested_context.mustache @@ -1 +1 @@ -{{#foo}}{{thing1}} and {{thing2}}{{/foo}}{{^foo}}Not foo!{{/foo}} \ No newline at end of file +{{#foo}}{{thing1}} and {{thing2}} and {{outer_thing}}{{/foo}}{{^foo}}Not foo!{{/foo}} diff --git a/examples/nested_context.py b/examples/nested_context.py index 62d2d51..2691802 100644 --- a/examples/nested_context.py +++ b/examples/nested_context.py @@ -3,5 +3,8 @@ import pystache class NestedContext(pystache.View): template_path = 'examples' + def outer_thing(self): + return "two" + def foo(self): return {'thing1': 'one', 'thing2': 'foo'} diff --git a/tests/test_examples.py b/tests/test_examples.py index af67735..9ad6c1e 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -69,7 +69,7 @@ Again, Welcome! """) def test_nested_context(self): - self.assertEquals(NestedContext().render(), "one and foo") + self.assertEquals(NestedContext().render(), "one and foo and two") if __name__ == '__main__': unittest.main()