From 5236d8cc7ef94d6f356047aadf8a3d5546ce904f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 17 Apr 2008 11:23:16 +0200 Subject: [PATCH] `TemplateData` -> `Markup` --HG-- branch : trunk --- jinja2/compiler.py | 7 ++++--- jinja2/runtime.py | 12 ++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 61f3917..ca25304 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -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: diff --git a/jinja2/runtime.py b/jinja2/runtime.py index 247958f..2b05e73 100644 --- a/jinja2/runtime.py +++ b/jinja2/runtime.py @@ -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>' % ( -- 2.26.2