summaryrefslogtreecommitdiff
path: root/examples/nested_context.py
blob: 83565a14719cba890fbf9cabe9a4dc96e07fa4f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pystache

class NestedContext(pystache.View):
    template_path = 'examples'

    def outer_thing(self):
        return "two"

    def foo(self):
        return {'thing1': 'one', 'thing2': 'foo'}

    def derp(self):
        return [{'inner': 'car'}]

    def herp(self):
        return [{'outer': 'car'}]

    def nested_context_in_view(self):
        if self.get('outer') == self.get('inner'):
            return 'it works!'
        return ''