diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-03 06:38:04 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-05-03 06:38:04 -0700 |
commit | 5a94c93b9ad263bf8497576ca4a5b8b0ca4cd581 (patch) | |
tree | 6bae0fb12088b2c2d70267a6eeaccb50108dddce /pystache/parser.py | |
parent | 27f2ae76cff07d8d7fc8dec06bc9698e3f0c0e51 (diff) | |
download | pystache-5a94c93b9ad263bf8497576ca4a5b8b0ca4cd581.tar.gz |
Addressed issue #115: "Match spec expectation for partials not found"
Diffstat (limited to 'pystache/parser.py')
-rw-r--r-- | pystache/parser.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/pystache/parser.py b/pystache/parser.py index 2b97405..4e05f3b 100644 --- a/pystache/parser.py +++ b/pystache/parser.py @@ -9,12 +9,13 @@ This module is only meant for internal use by the renderengine module. import re +from pystache.common import TemplateNotFoundError from pystache.parsed import ParsedTemplate -DEFAULT_DELIMITERS = ('{{', '}}') -END_OF_LINE_CHARACTERS = ['\r', '\n'] -NON_BLANK_RE = re.compile(r'^(.)', re.M) +DEFAULT_DELIMITERS = (u'{{', u'}}') +END_OF_LINE_CHARACTERS = [u'\r', u'\n'] +NON_BLANK_RE = re.compile(ur'^(.)', re.M) def _compile_template_re(delimiters=None): @@ -215,10 +216,14 @@ class Parser(object): elif tag_type == '>': - template = engine.load_partial(tag_key) + try: + # TODO: make engine.load() and test it separately. + template = engine.load_partial(tag_key) + except TemplateNotFoundError: + template = u'' # Indent before rendering. - template = re.sub(NON_BLANK_RE, leading_whitespace + r'\1', template) + template = re.sub(NON_BLANK_RE, leading_whitespace + ur'\1', template) func = engine._make_get_partial(template) |