from jinja2.visitor import NodeVisitor, NodeTransformer
from jinja2.exceptions import TemplateAssertionError
from jinja2.runtime import StaticLoopContext
+from jinja2.utils import Markup
operators = {
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:
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:
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:
__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):
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>' % (