Package genshi :: Package template :: Module directives :: Class WithDirective

Class WithDirective



object --+    
         |    
 Directive --+
             |
            WithDirective

Implementation of the py:with template directive, which allows shorthand access to variables and expressions.

>>> from genshi.template import MarkupTemplate
>>> tmpl = MarkupTemplate('''<div xmlns:py="http://genshi.edgewall.org/">
...   <span py:with="y=7; z=x+10">$x $y $z</span>
... </div>''')
>>> print tmpl.generate(x=42)
<div>
  <span>42 7 52</span>
</div>


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 = 'vars'
  tagname = 'with'
Properties
  vars

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__