comparison genshi/template/core.py @ 347:ffa7dea6e8fd experimental-inline

cspeedups branch: Merged [423:426/trunk].
author cmlenz
date Fri, 10 Nov 2006 17:38:50 +0000
parents d98a77b6094e
children 0b3e382325ef
comparison
equal deleted inserted replaced
344:bb881d1b4b5c 347:ffa7dea6e8fd
338 for kind, data, pos in stream: 338 for kind, data, pos in stream:
339 339
340 if kind is START and data[1]: 340 if kind is START and data[1]:
341 # Attributes may still contain expressions in start tags at 341 # Attributes may still contain expressions in start tags at
342 # this point, so do some evaluation 342 # this point, so do some evaluation
343 tag, attrib = data 343 tag, attrs = data
344 new_attrib = [] 344 new_attrs = []
345 for name, substream in attrib: 345 for name, substream in attrs:
346 if isinstance(substream, basestring): 346 if isinstance(substream, basestring):
347 value = substream 347 value = substream
348 else: 348 else:
349 values = [] 349 values = []
350 for subkind, subdata, subpos in self._eval(substream, 350 for subkind, subdata, subpos in self._eval(substream,
352 if subkind is TEXT: 352 if subkind is TEXT:
353 values.append(subdata) 353 values.append(subdata)
354 value = [x for x in values if x is not None] 354 value = [x for x in values if x is not None]
355 if not value: 355 if not value:
356 continue 356 continue
357 new_attrib.append((name, u''.join(value))) 357 new_attrs.append((name, u''.join(value)))
358 yield kind, (tag, Attrs(new_attrib)), pos 358 yield kind, (tag, Attrs(new_attrs)), pos
359 359
360 elif kind is EXPR: 360 elif kind is EXPR:
361 result = data.evaluate(ctxt) 361 result = data.evaluate(ctxt)
362 if result is not None: 362 if result is not None:
363 # First check for a string, otherwise the iterable test below 363 # First check for a string, otherwise the iterable test below
Copyright (C) 2012-2017 Edgewall Software