It’s just data

Genshi Templates for Venus

Earlier, I explored Genshi Filters for Venus, and compared them to XSLT.

Today, I implemented Genshi Templates.  Lets compare them to htmltmpl.

Excerpt from genshi_fancy:

<h3 py:if="entry.new_feed"><a href="$entry.link" title="$entry.source.title">$entry.source.config.name</a></h3>
<img py:if="entry.new_feed and entry.source.config.face" class="face" src="images/$entry.source.config.face" width="$entry.source.config.facewidth" height="$entry.source.config.faceheight" alt=""/>

Corresponding excerpt from classic_fancy:

<TMPL_IF new_channel>
<h3><a href="<TMPL_VAR channel_link ESCAPE="HTML">" title="<TMPL_VAR channel_title_plain ESCAPE="HTML">"><TMPL_VAR channel_name></a></h3>
<TMPL_IF channel_face>
<img class="face" src="images/<TMPL_VAR channel_face ESCAPE="HTML">" width="<TMPL_VAR channel_facewidth ESCAPE="HTML">" height="<TMPL_VAR channel_faceheight ESCAPE="HTML">" alt="">
</TMPL_IF>
</TMPL_IF>

Some of the differences are due to the variables passed into the templates.  See the documentation for details.


Sam Ruby: Genshi Templates for Venus

[link] [more]...

Excerpt from reddit.com: programming - newest submissions at

Did I see an alt="" there? Shame on you :-)

Posted by Martin Probst at

Did I see an alt="" there?

Yes, you did.  The intention of this exercise was to show that Genshi support in Venus can produce a faithful rendition of the existing “classic-fancy” theme produced using htmltmpl, which in turn is intended to produce identical results with what you would get with the “fancy” template in Planet 2.0.

Posted by Sam Ruby at

A suggestion for streamlining the Genshi snippet (untested):

<py:if test="entry.new_feed" py:with="config=entry.source.config">
  <h3><a href="$entry.link" title="$entry.source.title">$config.name</a></h3>
  <img py:if="config.face" class="face" src="images/$config.face"
       width="$config.facewidth" height="$config.faceheight" alt="" />
</py:if>
Posted by Christopher Lenz at

Add your comment