Edgewall Software

Opened 8 years ago

Closed 8 years ago

Last modified 2 years ago

#122 closed enhancement (fixed)

JQueryesque transformations of Genshi streams

Reported by: Alec Thomas <alec@…> Owned by: cmlenz
Priority: minor Milestone: 0.5
Component: General Version: devel
Keywords: Cc:


Implementation of a JQuery-like stream transformation filter. Best shown by example. The following copies the <title/> contents into the body, simultaneously enclosing it in <h1/>:

>>> from genshi import XML
>>> from genshi.builder import tag
>>> from genshi.filters.transform import Transform
>>> stream = XML('<html><head><title>Some Title</title></head><body>'
...                              'Some <em>body</em> text.</body></html>')
>>> buffer = []
>>> transform = Transform('.//title/text()').copy(buffer).select('.//body'). \
...                                           prepend(tag.h1(buffer))
>>> print stream | transform
<html><head><title>Some Title</title></head><body><h1>Some Title</h1>Some
 <em>body</em> text.</body></html>

Attachments (1)

genshi-transform.diff (29.3 KB) - added by Alec Thomas <alec@…> 8 years ago.
Genshi transform filter patch

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by Alec Thomas <alec@…>

Genshi transform filter patch

comment:1 Changed 8 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Checked in in [605]. Awesome work, thanks a lot!

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.