comparison genshi/template/markup.py @ 847:4f9e5e6f1aab

Backported a couple of templating core changes from the advanced-i18n branch, in particular considering the determination of directive ordering../set
author cmlenz
date Tue, 13 Oct 2009 18:12:55 +0000
parents 004f81b59d97
children 4376010bb97e
comparison
equal deleted inserted replaced
846:df0acf2a208d 847:4f9e5e6f1aab
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # 2 #
3 # Copyright (C) 2006-2008 Edgewall Software 3 # Copyright (C) 2006-2009 Edgewall Software
4 # All rights reserved. 4 # All rights reserved.
5 # 5 #
6 # This software is licensed as described in the file COPYING, which 6 # This software is licensed as described in the file COPYING, which
7 # you should have received as part of this distribution. The terms 7 # you should have received as part of this distribution. The terms
8 # are also available at http://genshi.edgewall.org/wiki/License. 8 # are also available at http://genshi.edgewall.org/wiki/License.
129 if cls is None: 129 if cls is None:
130 raise BadDirectiveError(tag.localname, 130 raise BadDirectiveError(tag.localname,
131 self.filepath, pos[1]) 131 self.filepath, pos[1])
132 args = dict([(name.localname, value) for name, value 132 args = dict([(name.localname, value) for name, value
133 in attrs if not name.namespace]) 133 in attrs if not name.namespace])
134 directives.append((cls, args, ns_prefix.copy(), pos)) 134 directives.append((factory.get_directive_index(cls), cls,
135 args, ns_prefix.copy(), pos))
135 strip = True 136 strip = True
136 137
137 new_attrs = [] 138 new_attrs = []
138 for name, value in attrs: 139 for name, value in attrs:
139 if name.namespace == namespace: 140 if name.namespace == namespace:
141 if cls is None: 142 if cls is None:
142 raise BadDirectiveError(name.localname, 143 raise BadDirectiveError(name.localname,
143 self.filepath, pos[1]) 144 self.filepath, pos[1])
144 if type(value) is list and len(value) == 1: 145 if type(value) is list and len(value) == 1:
145 value = value[0][1] 146 value = value[0][1]
146 directives.append((cls, value, ns_prefix.copy(), 147 directives.append((factory.get_directive_index(cls),
147 pos)) 148 cls, value, ns_prefix.copy(), pos))
148 else: 149 else:
149 new_attrs.append((name, value)) 150 new_attrs.append((name, value))
150 new_attrs = Attrs(new_attrs) 151 new_attrs = Attrs(new_attrs)
151 152
152 if directives: 153 if directives:
153 directives.sort(self.compare_directives()) 154 directives.sort()
154 dirmap[(depth, tag)] = (directives, len(new_stream), 155 dirmap[(depth, tag)] = (directives, len(new_stream),
155 strip) 156 strip)
156 157
157 new_stream.append((kind, (tag, new_attrs), pos)) 158 new_stream.append((kind, (tag, new_attrs), pos))
158 depth += 1 159 depth += 1
Copyright (C) 2012-2017 Edgewall Software