Move block into another block

14 views
Skip to first unread message

Mitar

unread,
Feb 14, 2009, 7:52:41 PM2/14/09
to gen...@googlegroups.com
Hi!

Why this does not work as I would expect:

<py:match path="div[@id='altlinks']">
<?python altlinks = select('*|text()') ?>
</py:match>
<py:match path="div[@id='ctxtnav']">
<div id="ctxtnav" class="nav">
${select('*|text()')}
${altlinks}
</div>
</py:match>

Is there any better/correct/working way of moving contents of altlinks
div into ctxtnav div in Trac?


Mitar

Leho Kraav

unread,
Sep 20, 2014, 8:36:16 PM9/20/14
to gen...@googlegroups.com

I'm looking for exactly this information - how to move divs around with Genshi. Did you ever figure it out?

Simon Cross

unread,
Sep 24, 2014, 7:08:32 PM9/24/14
to gen...@googlegroups.com
The following code:

# movediv.py
from genshi.template import MarkupTemplate

template = """<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/" lang="en">

<py:match path="div[@id='altlinks']">
<?python altlinks = select('*|text()') ?>
</py:match>
<py:match path="div[@id='ctxtnav']">
<div id="ctxtnav" class="nav">
${select('*|text()')}
${altlinks}
</div>
</py:match>

<div id="altlinks">
ALT LINKS
</div>
<div id="ctxtnav">
CTXTNAV
</div>

</html>"""

t = MarkupTemplate(template)
s = t.generate()

print s.render()
# end

Outputs the following for me on Genshi trunk:

$ python movediv.py
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<div id="ctxtnav" class="nav">
CTXTNAV
ALT LINKS
</div>
</html>

Which seems to do what people want? Not sure why the original poster
thought this didn't work?

Schiavo
Simon
Reply all
Reply to author
Forward
0 new messages