`TemplateData` -> `Markup`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent 26c0f51 · Browse files · 2 files·+6 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+6 added−13 removed
- other:+6 added−13 removed
Provenance
- Commit
5236d8c- Tree
9d851fe- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
26c0f51
2 files changed+6 added−13 removed
modified:jinja2/compiler.py+4 added-3 removed
13 unmodified lines14 from jinja2 import nodes15 from jinja2.visitor import NodeVisitor, NodeTransformer16 from jinja2.exceptions import TemplateAssertionError17 from jinja2.runtime import StaticLoopContext18+from jinja2.utils import Markup19 20 21 operators = {22 'eq': '==',27 unmodified lines50 """Does the node have a safe representation?"""51 if value is None or value is NotImplemented or value is Ellipsis:52 return True53 if isinstance(value, (bool, int, long, float, complex, basestring,53- xrange, StaticLoopContext)):54+ xrange, StaticLoopContext, Markup)):55 return True56 if isinstance(value, (tuple, list, set, frozenset)):57 for item in value:58 if not has_safe_repr(item):642 unmodified lines701 self.indent()702 self.pull_locals(macro_frame, indent=False)703 self.writeline('%s = []' % buf)704 self.blockvisit(node.body, macro_frame, indent=False)704- self.writeline("return TemplateData(u''.join(%s))" % buf)705+ self.writeline("return Markup(u''.join(%s))" % buf)706 self.outdent()707 self.newline()708 if frame.toplevel:709 self.write('context[%r] = ' % node.name)18 unmodified lines728 self.indent()729 self.pull_locals(call_frame, indent=False)730 self.writeline('%s = []' % buf)731 self.blockvisit(node.body, call_frame, indent=False)731- self.writeline("return TemplateData(u''.join(%s))" % buf)732+ self.writeline("return Markup(u''.join(%s))" % buf)733 self.outdent()734 arg_tuple = ', '.join(repr(x.name) for x in node.args)735 if len(node.args) == 1:736 arg_tuple += ','321 unmodified linesmodified:jinja2/runtime.py+2 added-10 removed
14 unmodified lines15 from jinja2.utils import Markup16 17 18 __all__ = ['LoopContext', 'StaticLoopContext', 'TemplateContext',19- 'Macro', 'IncludedTemplate', 'TemplateData']19+ 'Macro', 'IncludedTemplate', 'Markup']20 21 22-class TemplateData(Markup):23- """Marks data as "coming from the template". This is used to let the24- system know that this data is already processed if a finalization is25- used.26- """27- __slots__ = ()28-29-22 class TemplateContext(dict):23 """Holds the variables of the local template or of the global one. It's24 not save to use this class outside of the compiled code. For example25 update and other methods will not work as they seem (they don't update60 unmodified lines86 self._context = context87 self._render_func = render_func88 89 def __call__(self):98- return TemplateData(u''.join(self._render_func(self._context)))90+ return Markup(u''.join(self._render_func(self._context)))91 92 def __repr__(self):93 return '<%s %r>' % (94 self.__class__.__name__,225 unmodified lines