diff options
author | Chris Wanstrath <chris@ozmm.org> | 2009-10-30 11:12:17 -0700 |
---|---|---|
committer | Chris Wanstrath <chris@ozmm.org> | 2009-10-30 11:12:17 -0700 |
commit | 06c5544ee9b7e7b955cc9e32109c01338ff23495 (patch) | |
tree | 63fe3641b6d464fc0c9581444762438a49fb0495 | |
parent | 05a1c5756559ed47a3dff86a956d2ddee46cf00b (diff) | |
download | pystache-06c5544ee9b7e7b955cc9e32109c01338ff23495.tar.gz |
referencing basic view methods from a template works
-rw-r--r-- | pystache/view.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pystache/view.py b/pystache/view.py index 26ec8eb..40361a0 100644 --- a/pystache/view.py +++ b/pystache/view.py @@ -1,4 +1,4 @@ -import pystache +from pystache import Template import os.path class View(object): @@ -35,7 +35,12 @@ class View(object): def template_name(self): return self.__class__.__name__ + def get(self, attr, default): + if hasattr(self, attr): + return getattr(self, attr)() + else: + return default + def render(self): template = self.load_template() - return pystache.render(template, self.context) - + return Template(template, self).render() |