Edgewall Software

Opened 17 years ago

Closed 17 years ago

Last modified 11 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:

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 (1)

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

Download all attachments as: .zip

Change History (2)

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

Genshi transform filter patch

comment:1 Changed 17 years ago by cmlenz

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

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

Note: See TracTickets for help on using tickets.