genshi.template.text.OldTextTemplate

Package genshi :: Package template :: Module text :: Class OldTextTemplate |

# Class OldTextTemplate

               object --+
                        |
    base.DirectiveFactory --+
                            |
                base.Template --+
                                |
                               OldTextTemplate

Legacy implementation of the old syntax text-based templates. This class is provided in a transition phase for backwards compatibility. New code should use the NewTextTemplate class and the improved syntax it provides.

    >>> tmpl = OldTextTemplate('''Dear $name,
    ...
    ... We have the following items for you:
    ... #for item in items
    ...  * $item
    ... #end
    ...
    ... All the best,
    ... Foobar''')
    >>> print(tmpl.generate(name='Joe', items=[1, 2, 3]).render(encoding=None))
    Dear Joe,
    <BLANKLINE>
    We have the following items for you:
     * 1
     * 2
     * 3
    <BLANKLINE>
    All the best,
    Foobar

Nested Classes
Inherited from `base.DirectiveFactory`: `__metaclass__`

Instance Methods
Inherited from `base.Template`: `__getstate__`, `__init__`, `__repr__`, `__setstate__`, `generate` Inherited from `base.DirectiveFactory`: `get_directive`, `get_directive_index` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables
| directives = ``[``(``'``def``'``,` <class 'genshi.template.directives.DefDi`...`` A list of `(name, cls)` tuples that define the set of directives provided by this factory.
| serializer = ``'``text``'`` hash(x)
Inherited from `base.Template`: `EXEC`, `EXPR`, `INCLUDE`, `SUB`

Properties
Inherited from `base.Template`: `stream` Inherited from `object`: `__class__`

Class Variable Details

  ### directives A list of `(name, cls)` tuples that define the set of directives provided by this factory. Value:
      [('def', <class 'genshi.template.directives.DefDirective'>),
       ('when', <class 'genshi.template.directives.WhenDirective'>),
       ('otherwise',
        <class 'genshi.template.directives.OtherwiseDirective'>),
       ('for', <class 'genshi.template.directives.ForDirective'>),
       ('if', <class 'genshi.template.directives.IfDirective'>),
       ('choose', <class 'genshi.template.directives.ChooseDirective'>),
       ('with', <class 'genshi.template.directives.WithDirective'>)]