summaryrefslogtreecommitdiff
path: root/pystache
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-03 16:14:16 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-04 05:38:19 -0700
commit049a76c11318b3e389863f2f4a2e39fe73f7597a (patch)
tree82404fd7f691b64feb6bab468453ca23df1d716f /pystache
parent69c44762bbfbdbcf5c85e534af691f03150a82c7 (diff)
downloadpystache-049a76c11318b3e389863f2f4a2e39fe73f7597a.tar.gz
Added RenderEngine.resolve_context().
Diffstat (limited to 'pystache')
-rw-r--r--pystache/parser.py2
-rw-r--r--pystache/renderengine.py12
2 files changed, 8 insertions, 6 deletions
diff --git a/pystache/parser.py b/pystache/parser.py
index 5a56f4c..4851303 100644
--- a/pystache/parser.py
+++ b/pystache/parser.py
@@ -215,7 +215,7 @@ class Parser(object):
elif tag_type == '>':
- template = engine.read_partial(tag_key)
+ template = engine.resolve_partial(tag_key)
# Indent before rendering.
template = re.sub(NON_BLANK_RE, leading_whitespace + ur'\1', template)
func = engine._make_get_partial(template)
diff --git a/pystache/renderengine.py b/pystache/renderengine.py
index 4b0ba20..ddc7c75 100644
--- a/pystache/renderengine.py
+++ b/pystache/renderengine.py
@@ -65,8 +65,10 @@ class RenderEngine(object):
self.literal = literal
self.load_partial = load_partial
- # TODO: rename context to stack throughout this module.
- def read_partial(self, key):
+ def resolve_context(self, stack, name):
+ return stack.get(name)
+
+ def resolve_partial(self, key):
try:
return self.load_partial(key)
except TemplateNotFoundError:
@@ -77,7 +79,7 @@ class RenderEngine(object):
Get a value from the given context as a basestring instance.
"""
- val = context.get(tag_name)
+ val = self.resolve_context(context, tag_name)
if callable(val):
# According to the spec:
@@ -145,7 +147,7 @@ class RenderEngine(object):
"""
# TODO: is there a bug because we are not using the same
# logic as in _get_string_value()?
- data = context.get(name)
+ data = self.resolve_context(context, name)
# Per the spec, lambdas in inverted sections are considered truthy.
if data:
return u''
@@ -164,7 +166,7 @@ class RenderEngine(object):
"""
template = template_
parsed_template = parsed_template_
- data = context.get(name)
+ data = self.resolve_context(context, name)
# From the spec:
#