Templates

Template names take the form name.ext.type, where name.ext identifies the name of the output file to be created in the output_directory, and type indicates which language processor to use for the template.

Like with filters, templates may be written in a variety of languages and are based on the standard Unix pipe convention of producing stdout from stdin, but in practice two languages are used more than others:

htmltmpl

Many find htmltmpl easier to get started with as you can take a simple example of your output file, sprinkle in a few <TMPL_VAR>s and <TMPL_LOOP>s and you are done. Eventually, however, you may find that your template involves <TMPL_IF> blocks inside of attribute values, and you may find the result difficult to read and create correctly.

It is also important to note that htmltmpl based templates do not have access to the full set of information available in the feed, just the following (rather substantial) subset:

VARtypesource
authorStringauthor
author_nameStringauthor_detail.name
generatorStringgenerator
idStringid
iconStringicon
last_updated_822Rfc822updated_parsed
last_updated_isoRfc3399updated_parsed
last_updatedPlanetDateupdated_parsed
linkStringlink
logoStringlogo
rightsStringrights_detail.value
subtitleStringsubtitle_detail.value
titleStringtitle_detail.value
title_plainPlaintitle_detail.value
urlStringlinks[rel='self'].href
headers['location']

Note: when multiple sources are listed, the last one wins

In addition to these variables, Planet Venus makes available two arrays, Channels and Items, with one entry per subscription and per output entry respectively. The data values within the Channels array exactly match the above list. The data values within the Items array are as follows:

VARtypesource
authorStringauthor
author_emailStringauthor_detail.email
author_nameStringauthor_detail.name
author_uriStringauthor_detail.href
content_languageStringcontent[0].language
contentStringsummary_detail.value
content[0].value
datePlanetDatepublished_parsed
updated_parsed
date_822Rfc822published_parsed
updated_parsed
date_isoRfc3399published_parsed
updated_parsed
enclosure_hrefStringenclosures[0].href
enclosure_lengthStringenclosures[0].length
enclosure_typeStringenclosures[0].type
guid_isPermaLinkStringisPermaLink
idStringid
linkStringlinks[rel='alternate'].href
new_channelStringid
new_dateNewDatepublished_parsed
updated_parsed
rightsStringrights_detail.value
title_languageStringtitle_detail.language
title_plainPlaintitle_detail.value
titleStringtitle_detail.value
summary_languageStringsummary_detail.language
updatedPlanetDateupdated_parsed
updated_822Rfc822updated_parsed
updated_isoRfc3399updated_parsed
publishedPlanetDatepublished_parsed
published_822Rfc822published_parsed
published_isoRfc3399published_parsed

Note: variables above which start with new_ are only set if their values differ from the previous Item.

django

If you have the Django framework installed, Django templates are automatically available to Venus projects. You will have to save them with a .html.dj extension in your themes. The variable set is the same as the one from htmltmpl, above. In the Django template context you'll have access to Channels and Items and you'll be able to iterate through them.

You also have access to the Config dictionary, which contains the Venus configuration variables from your .ini file.

If you lose your way and want to introspect all the variable in the context, there's the useful {% debug %} template tag.

In the themes/django/ you'll find a sample Venus theme that uses the Django templates that might be a starting point for your own custom themes.

All the standard Django template tags and filter are supposed to work, with the notable exception of the date filter on the updated and published dates of an item (it works on the main {{ date }} variable).

Please note that Django, and therefore Venus' Django support, requires at least Python 2.3.

xslt

XSLT is a paradox: it actually makes some simple things easier to do than htmltmpl, and certainly can make more difficult things possible; but it is fair to say that many find XSLT less approachable than htmltmpl.

But in any case, the XSLT support is easier to document as the input is a highly normalized feed, with a few extension elements.

genshi

Genshi approaches the power of XSLT, but with a syntax that many Python programmers find more natural, succinct and expressive. Genshi templates have access to the full range of feedparser values, with the following additions: