summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wanstrath <chris@ozmm.org>2009-11-16 21:29:52 -0800
committerChris Wanstrath <chris@ozmm.org>2009-11-16 21:29:52 -0800
commit6e83a2e382481aa0036e7a9ff3346da6cc29c5a9 (patch)
tree20e8dbe4628bfd9a94ff9b516c72d1dff80c205e
parent08b06f9cabffe7750511250526e73205cbe82c40 (diff)
downloadpystache-6e83a2e382481aa0036e7a9ff3346da6cc29c5a9.tar.gz
Revert "Better way to perform callable check. Allow callables from context attributes."
This reverts commit 08b06f9cabffe7750511250526e73205cbe82c40.
-rw-r--r--pystache/view.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/pystache/view.py b/pystache/view.py
index 5c2fc10..a7a7de2 100644
--- a/pystache/view.py
+++ b/pystache/view.py
@@ -76,12 +76,15 @@ class View(object):
return re.sub('[A-Z]', repl, name)[1:]
def get(self, attr, default):
- attr = self.context.get(attr, getattr(self, attr, default))
-
- if callable(attr):
- return attr()
+ if attr in self.context:
+ return self.context[attr]
+ elif hasattr(self, attr):
+ try:
+ return getattr(self, attr)()
+ except TypeError:
+ return getattr(self, attr)
else:
- return attr
+ return default
def render(self):
template = self.load_template()