TemplateData -> Markup

--HG--
branch : trunk
This commit is contained in:
Armin Ronacher 2008-04-17 11:23:16 +02:00
parent 26c0f51140
commit 5236d8cc7e
2 changed files with 6 additions and 13 deletions

View File

@ -15,6 +15,7 @@ from jinja2 import nodes
from jinja2.visitor import NodeVisitor, NodeTransformer
from jinja2.exceptions import TemplateAssertionError
from jinja2.runtime import StaticLoopContext
from jinja2.utils import Markup
operators = {
@ -50,7 +51,7 @@ def has_safe_repr(value):
if value is None or value is NotImplemented or value is Ellipsis:
return True
if isinstance(value, (bool, int, long, float, complex, basestring,
xrange, StaticLoopContext)):
xrange, StaticLoopContext, Markup)):
return True
if isinstance(value, (tuple, list, set, frozenset)):
for item in value:
@ -701,7 +702,7 @@ class CodeGenerator(NodeVisitor):
self.pull_locals(macro_frame, indent=False)
self.writeline('%s = []' % buf)
self.blockvisit(node.body, macro_frame, indent=False)
self.writeline("return TemplateData(u''.join(%s))" % buf)
self.writeline("return Markup(u''.join(%s))" % buf)
self.outdent()
self.newline()
if frame.toplevel:
@ -728,7 +729,7 @@ class CodeGenerator(NodeVisitor):
self.pull_locals(call_frame, indent=False)
self.writeline('%s = []' % buf)
self.blockvisit(node.body, call_frame, indent=False)
self.writeline("return TemplateData(u''.join(%s))" % buf)
self.writeline("return Markup(u''.join(%s))" % buf)
self.outdent()
arg_tuple = ', '.join(repr(x.name) for x in node.args)
if len(node.args) == 1:

View File

@ -16,15 +16,7 @@ from jinja2.utils import Markup
__all__ = ['LoopContext', 'StaticLoopContext', 'TemplateContext',
'Macro', 'IncludedTemplate', 'TemplateData']
class TemplateData(Markup):
"""Marks data as "coming from the template". This is used to let the
system know that this data is already processed if a finalization is
used.
"""
__slots__ = ()
'Macro', 'IncludedTemplate', 'Markup']
class TemplateContext(dict):
@ -95,7 +87,7 @@ class SuperBlock(object):
self._render_func = render_func
def __call__(self):
return TemplateData(u''.join(self._render_func(self._context)))
return Markup(u''.join(self._render_func(self._context)))
def __repr__(self):
return '<%s %r>' % (