Edgewall Software

Ticket #122 (closed enhancement: fixed)

Opened 7 years ago

Last modified 16 months ago

JQueryesque transformations of Genshi streams

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

Description

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

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

Change History

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

Genshi transform filter patch

Changed 7 years ago by cmlenz

  • status changed from new to closed
  • resolution set to fixed

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

Add/Change #122 (JQueryesque transformations of Genshi streams)

Author


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


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.