Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Genshi (templating language)

From Wikipedia, the free encyclopedia
Genshi
DeveloperEdgewall Software
Initial releaseAugust 3, 2006; 19 years ago (2006-08-03)
Stable release
0.7.10[1] Edit this on Wikidata / 30 November 2025; 2 months ago (30 November 2025)
Operating systemCross-platform
TypeTemplate Engine
License3-clause BSD license[2]
Websitegenshi.edgewall.org
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 markup

[edit]

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]

Differences between Kid and Genshi

[edit]
  • Genshi directly interprets templates (unlike Kid, which generates Python code)[13]
  • Genshi usesXInclude for template reuse[13]
  • Genshi adds attributes Kid does not have, likepy: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'sgenerated code.[13]

References

[edit]
  1. ^"Release 0.7.10". 30 November 2025. Retrieved2 December 2025.
  2. ^"License – Genshi".
  3. ^"What is Genshi?". Retrieved2008-01-20.
  4. ^"CherryPy – Genshi". Retrieved2009-09-26.
  5. ^"Genshi - CherryPy Tools - Trac". Archived fromthe original on 2012-02-27. Retrieved2009-09-26.
  6. ^"Genshi Templating". Archived fromthe original on 2012-07-16. Retrieved2008-01-20.
  7. ^"Genshi Templates - Pylons Cookbook". Archived fromthe original on 2012-04-16. Retrieved2008-01-20.
  8. ^"web2py: Enterprise Web Framework". Retrieved2009-09-26.
  9. ^Ramm, Mark."TurboGears 1.1 and Beyond". Archived fromthe original on 2012-07-05. Retrieved2008-01-20.
  10. ^Molina, Alessandro."Docs Review". Retrieved2024-01-18.
  11. ^"Choosing a templating language". Archived fromthe original on 2010-06-16. Retrieved2010-05-30.
  12. ^"Choosing a templating language". Archived fromthe original on 2008-01-17. Retrieved2008-01-20.
  13. ^abcd"Comparing Genshi to Kid". Retrieved2008-01-20.

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Genshi_(templating_language)&oldid=1329115542"
Categories:
Hidden category:

[8]ページ先頭

©2009-2026 Movatter.jp