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.
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 atA 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>
- Use a py:if element to avoid the same test on both the h3 and the img
- Alias “entry.source.config” to “config”; note that this won’t overwrite an already existing “config” variable in an outer scope.
- Use a link break in the img element. Genshi will put the whole tag on a single line anyway.
Sam Ruby: Genshi Templates for Venus
[link] [more]...Excerpt from reddit.com: programming - newest submissions at