| Genshi | |
|---|---|
| Developer | Edgewall Software |
| Initial release | August 3, 2006; 19 years ago (2006-08-03) |
| Stable release | |
| Operating system | Cross-platform |
| Type | Template Engine |
| License | 3-clause BSD license[2] |
| Website | genshi |
| Repository | |
Genshi is atemplate engine forXML-based vocabularies written inPython. Genshi is used to easily insert generated output into XML-based languages, usuallyHTML, and reuse elements between documents. Genshi's syntax is based onKid, but its architecture is different. Genshi aims to implement some of its functionality while processing templates faster, by dynamically processing templates using a stream based API, instead of compiling templates to Python code.[3]
Genshi can be used with several Pythonweb frameworks, such asCherryPy,[4][5]TurboGears,[6]Pylons[7] andweb2py.[8] Genshi was the default templating language for TurboGears from versions 1.1[9] to 2.3.8.[10]
Genshi makes use ofnamespaces to embed instructions into HTML. A typical instruction is given as anattribute, with a Python expression inside the quotes. For example, the following will render a paragraph that shows 4:
<htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:py="http://genshi.edgewall.org/"><body><ppy:content="2+2">This will be replaced with 4</p></body></html>
Because of the use of namespaces, Genshi can be used inWYSIWYGHTML editors.[11][12]
py:choose[13]