Genshi (templating language)
From Wikipedia, the free encyclopedia
Please help improve this article or section by expanding it. Further information might be found on the talk page or at requests for expansion. (January 2008) |
Genshi is a template engine for XML-based vocabularies written in Python. Genshi is used to easily insert generated output into XML-based languages, usually HTML, and reuse elements between documents. Genshi is based on Kid and aims to implement some of its functionality while processing templates faster.[1]
Genshi's can be used with several Python web frameworks, such as TurboGears[2] and Pylons.[3] Genshi will eventually replace Kid in the TurboGears web framework.[4]
Contents |
[edit] Genshi Markup
Genshi makes use of namespaces to embed instructions into HTML. A typical instruction is given as an attribute, with a Python expression inside the quotes. For example, the following will render a paragraph that shows 4:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
<body>
<p py:content="2 + 2">This will be replaced with 4</p>
</body>
</html>
Because of the use of namespaces, Genshi can be used in WYSIWYG HTML editors.[5]
[edit] Differences between Kid and Genshi
- Genshi directly interprets templates (unlike Kid, which generates Python code)[6]
- Genshi uses XInclude for template reuse[6]
- Genshi adds attributes Kid does not have, like
py:choose
[6]
[edit] References
- ^ What is Genshi?. Retrieved on 2008-01-20.
- ^ Genshi Templating. Retrieved on 2008-01-20.
- ^ Genshi Templates - Pylons Cookbook. Retrieved on 2008-01-20.
- ^ Ramm, Mark. TurboGears 1.1 and Beyond. Retrieved on 2008-01-20.
- ^ Choosing a templating language. Retrieved on 2008-01-20.
- ^ a b c Comparing Genshi to Kid. Retrieved on 2008-01-20.