Ticket #14765: little_tweak_of_tempate_rendering2.patch
File little_tweak_of_tempate_rendering2.patch, 2.3 KB (added by , 13 years ago) |
---|
-
django/template/base.py
735 735 nodes.extend(nodelist.get_nodes_by_type(nodetype)) 736 736 return nodes 737 737 738 def mark_safe_unicode(bits): 739 return mark_safe(''.join([force_unicode(b) for b in bits])) 740 738 741 class NodeList(list): 739 742 # Set to True the first time a non-TextNode is inserted by 740 743 # extend_nodelist(). … … 747 750 bits.append(self.render_node(node, context)) 748 751 else: 749 752 bits.append(node) 750 return mark_safe (''.join([force_unicode(b) for b in bits]))753 return mark_safe_unicode(bits) 751 754 752 755 def get_nodes_by_type(self, nodetype): 753 756 "Return a list of all nodes of the given type" -
django/template/defaulttags.py
5 5 from datetime import datetime 6 6 from itertools import groupby, cycle as itertools_cycle 7 7 8 from django.template.base import Node, NodeList, Template, Context, Variable 8 from django.template.base import Node, NodeList, Template, Context, Variable, mark_safe_unicode 9 9 from django.template.base import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END 10 10 from django.template.base import get_library, Library, InvalidTemplateLibrary 11 11 from django.template.smartif import IfParser, Literal … … 194 194 if len_values < 1: 195 195 context.pop() 196 196 return self.nodelist_empty.render(context) 197 nodelist = NodeList()197 nodelist = [] 198 198 if self.is_reversed: 199 199 values = reversed(values) 200 200 unpack = len(self.loopvars) > 1 … … 235 235 # context. 236 236 context.pop() 237 237 context.pop() 238 return nodelist.render(context)238 return mark_safe_unicode(nodelist) 239 239 240 240 class IfChangedNode(Node): 241 241 child_nodelists = ('nodelist_true', 'nodelist_false')