To change a KID template into a Genshi format, all you have to do is:
1. in all templates except SiteTemplate replace:
<?python
kid.enable_import()
kid.reloadbases=True
import SiteTemplate
?>
<html py:layout="SiteTemplate"
xmlns:py="http://purl.org/kid/ns#"
xmlns="http://www.w3.org/1999/xhtml">
with:
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
2. Add:
<xi:include href="SiteTemplate.html" />
to every template file except SiteTemplate.html .
3. In SiteTemplate, change:
<?python
kid.reloadbases=True
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://purl.org/kid/ns#">
to:
<html xmlns:py="http://genshi.edgewall.org/" py:strip="">
4. wrap all turbogears widget calls in ET(), for example:
${ET(form.display(value=entry,
submit_text=_(u'Publish'),
action=tg.url('/add_article'),
form_attrs=dict(id='articleform'), tags=tags))}
And that's it. Hopefully, this concludes the mind-numbing template translations for now.
Next step: using ngettext() for things like "There are N Comments for this article".
Več o tem…