Skip to content
Myr

`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

2 files+6 added−13 removed

modified:jinja2/compiler.py+4 added-3 removed
13 unmodified lines
14from jinja2 import nodes15from jinja2.visitor import NodeVisitor, NodeTransformer16from jinja2.exceptions import TemplateAssertionError17from jinja2.runtime import StaticLoopContext18from jinja2.utils import Markup192021operators = {22 'eq': '==',
27 unmodified lines
50 """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 lines
701 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 lines
728 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 lines
modified:jinja2/runtime.py+2 added-10 removed
14 unmodified lines
15from jinja2.utils import Markup161718__all__ = ['LoopContext', 'StaticLoopContext', 'TemplateContext',19 'Macro', 'IncludedTemplate', 'TemplateData']19 'Macro', 'IncludedTemplate', 'Markup']202122class 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__ = ()282922class 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 update
60 unmodified lines
86 self._context = context87 self._render_func = render_func8889 def __call__(self):98 return TemplateData(u''.join(self._render_func(self._context)))90 return Markup(u''.join(self._render_func(self._context)))9192 def __repr__(self):93 return '<%s %r>' % (94 self.__class__.__name__,
225 unmodified lines