Package genshi :: Package template :: Module directives :: Class ForDirective

Class ForDirective



object --+    
         |    
 Directive --+
             |
            ForDirective

Implementation of the py:for template directive for repeating an element based on an iterable in the context data.

>>> from genshi.template import MarkupTemplate
>>> tmpl = MarkupTemplate('''<ul xmlns:py="http://genshi.edgewall.org/">
...   <li py:for="item in items">${item}</li>
... </ul>''')
>>> print tmpl.generate(items=[1, 2, 3])
<ul>
  <li>1</li><li>2</li><li>3</li>
</ul>


Nested Classes

Inherited from Directive: __metaclass__

Instance Methods
 
__init__(self, value, template, namespaces=None, lineno=-1, offset=-1)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__call__(self, stream, ctxt, directives)
Apply the directive to the given stream.
 
__repr__(self)
repr(x)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Methods

Inherited from Directive: attach

Class Variables
  ATTRIBUTE = 'each'
  tagname = 'for'
Properties
  assign
  filename

Inherited from Directive: expr

Inherited from object: __class__

Method Details

__init__(self, value, template, namespaces=None, lineno=-1, offset=-1)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: Directive.__init__

__call__(self, stream, ctxt, directives)
(Call operator)

 
Apply the directive to the given stream.
Overrides: Directive.__call__
(inherited documentation)

__repr__(self)
(Representation operator)

 
repr(x)
Overrides: Directive.__repr__