Package genshi :: Package filters :: Module transform :: Class InjectorTransformation |

# Class InjectorTransformation

    object --+
             |
            InjectorTransformation

Known Subclasses:
  - AfterTransformation
  - , AppendTransformation
  - , BeforeTransformation
  - , PrependTransformation
  - , ReplaceTransformation

Abstract base class for transformations that inject content into a stream.

    >>> class Top(InjectorTransformation):
    ...     def __call__(self, stream):
    ...         for event in self._inject():
    ...             yield event
    ...         for event in stream:
    ...             yield event
    >>> html = HTML('<body>Some <em>test</em> text</body>')
    >>> print html | Transformer('.//em').apply(Top('Prefix '))
    Prefix <body>Some <em>test</em> text</body>

Instance Methods
__init__(self, content) Create a new injector. |
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, content) (Constructor) |
Create a new injector. Parameters: `content` - An iterable of Genshi stream events, or a string to be injected. Overrides: object.__init__