=== modified file 'django/template/__init__.py'
|
|
|
717 | 717 | |
718 | 718 | class NodeList(list): |
719 | 719 | def render(self, context): |
720 | | bits = [] |
721 | | for node in self: |
722 | | if isinstance(node, Node): |
723 | | bits.append(self.render_node(node, context)) |
724 | | else: |
725 | | bits.append(node) |
726 | | return ''.join(bits) |
| 720 | return ''.join([node.render(context) for node in self]) |
727 | 721 | |
728 | 722 | def get_nodes_by_type(self, nodetype): |
729 | 723 | "Return a list of all nodes of the given type" |
… |
… |
|
732 | 726 | nodes.extend(node.get_nodes_by_type(nodetype)) |
733 | 727 | return nodes |
734 | 728 | |
735 | | def render_node(self, node, context): |
736 | | return(node.render(context)) |
737 | | |
738 | 729 | class DebugNodeList(NodeList): |
739 | | def render_node(self, node, context): |
740 | | try: |
741 | | result = node.render(context) |
742 | | except TemplateSyntaxError, e: |
743 | | if not hasattr(e, 'source'): |
744 | | e.source = node.source |
745 | | raise |
746 | | except Exception, e: |
747 | | from sys import exc_info |
748 | | wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e) |
749 | | wrapped.source = node.source |
750 | | wrapped.exc_info = exc_info() |
751 | | raise wrapped |
752 | | return result |
| 730 | def render(self, context): |
| 731 | bits = [] |
| 732 | for node in self: |
| 733 | try: |
| 734 | bits.append(node.render(context)) |
| 735 | except TemplateSyntaxError, e: |
| 736 | if not hasattr(e, 'source'): |
| 737 | e.source = node.source |
| 738 | raise |
| 739 | except Exception, e: |
| 740 | from sys import exc_info |
| 741 | wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e) |
| 742 | wrapped.source = node.source |
| 743 | wrapped.exc_info = exc_info() |
| 744 | raise wrapped |
| 745 | return ''.join(bits) |
753 | 746 | |
754 | 747 | class TextNode(Node): |
755 | 748 | def __init__(self, s): |
=== modified file 'django/template/defaulttags.py'
|
|
|
95 | 95 | return nodes |
96 | 96 | |
97 | 97 | def render(self, context): |
98 | | nodelist = NodeList() |
| 98 | nodelist = [] |
99 | 99 | if 'forloop' in context: |
100 | 100 | parentloop = context['forloop'] |
101 | 101 | else: |
… |
… |
|
141 | 141 | # context. |
142 | 142 | context.pop() |
143 | 143 | context.pop() |
144 | | return nodelist.render(context) |
| 144 | return ''.join(nodelist) |
145 | 145 | |
146 | 146 | class IfChangedNode(Node): |
147 | 147 | def __init__(self, nodelist, *varlist): |