Package tdi :: Package tools :: Module css :: Class CSSInlineFilter
[frames] | no frames]

Class CSSInlineFilter

source code

             object --+    
                      |    
filters.BaseEventFilter --+
                          |
                         CSSInlineFilter

TDI filter for modifying inline css
Instance Methods
 
__init__(self, builder, modifier, strip_empty=True, standalone=False)
Initialization
source code
 
handle_starttag(self, name, attr, closed, data)
Handle starttag
source code
 
handle_endtag(self, name, data)
Handle endtag
source code
 
handle_text(self, data)
Handle text
source code

Inherited from filters.BaseEventFilter: __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables

Inherited from filters.BaseEventFilter: builder

Properties

Inherited from object: __class__

Method Details

__init__(self, builder, modifier, strip_empty=True, standalone=False)
(Constructor)

source code 
Initialization
Parameters:
  • builder (tdi.interfaces.BuildingListenerInterface) - Builder
  • modifier (callable) - Modifier function. Takes a style and returns the (possibly) modified result.
  • strip_empty (bool) - Strip empty style elements?
  • standalone (bool) - Standalone context? In this case, we won't watch out for TDI attributes.
Overrides: object.__init__

handle_starttag(self, name, attr, closed, data)

source code 

Handle starttag

Style starttags are delayed until the endtag is found. The whole element is then evaluated (and possibly thrown away).

handle_endtag(self, name, data)

source code 

Handle endtag

When currently collecting, it must be a style endtag. The style element content is then cleaned up (using cleanup) and then modified (using the modifiy function passed during initialization). The result replaces the original. If it's empty and the starttag does not provide a tdi attribute and the filter was configured to do so: the whole element is thrown away.

handle_text(self, data)

source code 

Handle text

While collecting style text, the received data is buffered. Otherwise the event is just passed through.