Commit 9497c957 by Chris Jerdonek

6 more tests passing: handle call() returning None.

Now at--

    Ran 160 tests in 0.755s
    FAILED (errors=1, failures=18)
parent 444b0dc3
...@@ -23,6 +23,10 @@ def call(val, view, template=None): ...@@ -23,6 +23,10 @@ def call(val, view, template=None):
val = val(template) val = val(template)
else: else:
val = val(view, template) val = val(view, template)
if val is None:
val = ''
return unicode(val) return unicode(val)
def parse(template, view, delims=('{{', '}}')): def parse(template, view, delims=('{{', '}}')):
...@@ -34,7 +38,8 @@ def parse(template, view, delims=('{{', '}}')): ...@@ -34,7 +38,8 @@ def parse(template, view, delims=('{{', '}}')):
def renderParseTree(parsed, view, template): def renderParseTree(parsed, view, template):
n = len(parsed) n = len(parsed)
return ''.join(map(call, parsed, [view] * n, [template] * n)) parts = map(call, parsed, [view] * n, [template] * n)
return ''.join(parts)
def render(template, view, delims=('{{', '}}')): def render(template, view, delims=('{{', '}}')):
parseTree = parse(template, view, delims) parseTree = parse(template, view, delims)
...@@ -84,7 +89,8 @@ def escapedTag(name, delims): ...@@ -84,7 +89,8 @@ def escapedTag(name, delims):
def unescapedTag(name, delims): def unescapedTag(name, delims):
def func(context): def func(context):
template = call(val=context.get(name), view=context) val = context.get(name)
template = call(val=val, view=context)
return unicode(render(template, context)) return unicode(render(template, context))
return func return func
......
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