Package tdi :: Package tools :: Module javascript :: Class JSInlineFilter
[frames] | no frames]

Class JSInlineFilter

source code

             object --+    
                      |    
filters.BaseEventFilter --+
                          |
                         JSInlineFilter

TDI filter for modifying inline javascript
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 script and returns the (possibly) modified result.
  • strip_empty (bool) - Strip empty script 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

Script 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 script endtag. The script element content is then modified (using the modifiy function passed during initialization). The result replaces the original. If it's empty and the starttag neither provides src nor tdi attributes and the filter was configured to do so: the whole element is thrown away.

handle_text(self, data)

source code 

Handle text

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