Commit 69c44762 by Chris Jerdonek

Moved the partial-loading code from the parser module to the renderengine module.

parent 170c65df
...@@ -9,7 +9,6 @@ This module is only meant for internal use by the renderengine module. ...@@ -9,7 +9,6 @@ This module is only meant for internal use by the renderengine module.
import re import re
from pystache.common import TemplateNotFoundError
from pystache.parsed import ParsedTemplate from pystache.parsed import ParsedTemplate
...@@ -216,15 +215,9 @@ class Parser(object): ...@@ -216,15 +215,9 @@ class Parser(object):
elif tag_type == '>': elif tag_type == '>':
try: template = engine.read_partial(tag_key)
# TODO: make engine.load() and test it separately.
template = engine.load_partial(tag_key)
except TemplateNotFoundError:
template = u''
# Indent before rendering. # Indent before rendering.
template = re.sub(NON_BLANK_RE, leading_whitespace + ur'\1', template) template = re.sub(NON_BLANK_RE, leading_whitespace + ur'\1', template)
func = engine._make_get_partial(template) func = engine._make_get_partial(template)
else: else:
......
...@@ -7,6 +7,7 @@ Defines a class responsible for rendering logic. ...@@ -7,6 +7,7 @@ Defines a class responsible for rendering logic.
import re import re
from pystache.common import TemplateNotFoundError
from pystache.parser import Parser from pystache.parser import Parser
...@@ -65,6 +66,12 @@ class RenderEngine(object): ...@@ -65,6 +66,12 @@ class RenderEngine(object):
self.load_partial = load_partial self.load_partial = load_partial
# TODO: rename context to stack throughout this module. # 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): def _get_string_value(self, context, tag_name):
""" """
Get a value from the given context as a basestring instance. Get a value from the given context as a basestring instance.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment