diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-03 13:46:46 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-04 05:38:19 -0700 |
commit | 69c44762bbfbdbcf5c85e534af691f03150a82c7 (patch) | |
tree | c904f092c985a1b8170a26747309faa1880973e3 | |
parent | 170c65df0b0d4eed75997b2eee05dd755b301d3b (diff) | |
download | pystache-69c44762bbfbdbcf5c85e534af691f03150a82c7.tar.gz |
Moved the partial-loading code from the parser module to the renderengine module.
-rw-r--r-- | pystache/parser.py | 9 | ||||
-rw-r--r-- | pystache/renderengine.py | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/pystache/parser.py b/pystache/parser.py index 4e05f3b..5a56f4c 100644 --- a/pystache/parser.py +++ b/pystache/parser.py @@ -9,7 +9,6 @@ This module is only meant for internal use by the renderengine module. import re -from pystache.common import TemplateNotFoundError from pystache.parsed import ParsedTemplate @@ -216,15 +215,9 @@ class Parser(object): elif tag_type == '>': - try: - # TODO: make engine.load() and test it separately. - template = engine.load_partial(tag_key) - except TemplateNotFoundError: - template = u'' - + template = engine.read_partial(tag_key) # Indent before rendering. template = re.sub(NON_BLANK_RE, leading_whitespace + ur'\1', template) - func = engine._make_get_partial(template) else: diff --git a/pystache/renderengine.py b/pystache/renderengine.py index e1d57e4..4b0ba20 100644 --- a/pystache/renderengine.py +++ b/pystache/renderengine.py @@ -7,6 +7,7 @@ Defines a class responsible for rendering logic. import re +from pystache.common import TemplateNotFoundError from pystache.parser import Parser @@ -65,6 +66,12 @@ class RenderEngine(object): self.load_partial = load_partial # TODO: rename context to stack throughout this module. + def read_partial(self, key): + try: + return self.load_partial(key) + except TemplateNotFoundError: + return u'' + def _get_string_value(self, context, tag_name): """ Get a value from the given context as a basestring instance. |