Genshi (templating language)
| Genshi | |
|---|---|
| Developer | Edgewall Software |
| Initial release | August 3, 2006; 19 years ago (2006年08月03日) |
| Stable release | |
| Repository | |
| Operating system | Cross-platform |
| Type | Template Engine |
| License | 3-clause BSD license[2] |
| Website | genshi |
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's syntax is based on Kid, 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 Python web frameworks, such as CherryPy,[4] [5] TurboGears,[6] Pylons [7] and web2py.[8] Genshi was the default templating language for TurboGears from versions 1.1[9] to 2.3.8.[10]
Genshi markup
[edit ]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.[11] [12]
Differences between Kid and Genshi
[edit ]- Genshi directly interprets templates (unlike Kid, which generates Python code)[13]
- Genshi uses XInclude for template reuse[13]
- Genshi adds attributes Kid does not have, like
py:choose[13] - Genshi templates are easier to debug, because it tracks template source file names and line numbers, and errors from Genshi's interpreter produce more comprehensible stack traces than from Kid's generated code.[13]
References
[edit ]- ^ "Release 0.7.9". 15 June 2024. Retrieved 22 June 2024.
- ^ "License – Genshi".
- ^ "What is Genshi?" . Retrieved 2008年01月20日.
- ^ "CherryPy – Genshi" . Retrieved 2009年09月26日.
- ^ "Genshi - CherryPy Tools - Trac". Archived from the original on 2012年02月27日. Retrieved 2009年09月26日.
- ^ "Genshi Templating". Archived from the original on 2012年07月16日. Retrieved 2008年01月20日.
- ^ "Genshi Templates - Pylons Cookbook". Archived from the original on 2012年04月16日. Retrieved 2008年01月20日.
- ^ "web2py: Enterprise Web Framework" . Retrieved 2009年09月26日.
- ^ Ramm, Mark. "TurboGears 1.1 and Beyond". Archived from the original on 2012年07月05日. Retrieved 2008年01月20日.
- ^ Molina, Alessandro. "Docs Review" . Retrieved 2024年01月18日.
- ^ "Choosing a templating language". Archived from the original on 2010年06月16日. Retrieved 2010年05月30日.
- ^ "Choosing a templating language". Archived from the original on 2008年01月17日. Retrieved 2008年01月20日.
- ^ a b c d "Comparing Genshi to Kid" . Retrieved 2008年01月20日.