HOME

TheInfoList



OR:

Genshi is a template engine for
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. T ...
-based vocabularies written in Python. Genshi is used to easily insert generated output into XML-based languages, usually
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaS ...
, 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. Genshi can be used with several Python
web framework A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build an ...
s, such as
CherryPy CherryPy is an object-oriented web application framework using the Python programming language. It is designed for rapid development of web applications by wrapping the HTTP protocol but stays at a low level and does not offer much more than wha ...
,
TurboGears TurboGears is a Python web application framework consisting of several WSGI components such as WebOb, SQLAlchemyKajikitemplate language and Repoze. TurboGears is designed around the model–view–controller (MVC) architecture, much like Stru ...
,
Pylons Pylon may refer to: Structures and boundaries * Pylon (architecture), the gateway to the inner part of an Ancient Egyptian temple or Christian cathedral * Pylon, a support tower structure for suspension bridges or highways * Pylon, an orange mar ...
and
web2py Web2py is an open-source web application framework written in the Python programming language. Web2py allows web developers to program dynamic web content using Python. Web2py is designed to help reduce tedious web development tasks, such a ...
. Genshi has replaced Kid in the
TurboGears TurboGears is a Python web application framework consisting of several WSGI components such as WebOb, SQLAlchemyKajikitemplate language and Repoze. TurboGears is designed around the model–view–controller (MVC) architecture, much like Stru ...
2.x web framework.


Genshi markup

Genshi makes use of
namespaces In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. Namespaces ...
to embed instructions into HTML. A typical instruction is given as an
attribute Attribute may refer to: * Attribute (philosophy), an extrinsic property of an object * Attribute (research), a characteristic of an object * Grammatical modifier, in natural languages * Attribute (computing), a specification that defines a prope ...
, with a Python expression inside the quotes. For example, the following will render a paragraph that shows 4:

This will be replaced with 4

Because of the use of namespaces, Genshi can be used in
WYSIWYG In computing, WYSIWYG ( ), an acronym for What You See Is What You Get, is a system in which editing software allows content to be edited in a form that resembles its appearance when printed or displayed as a finished product, such as a printed d ...
HTML editor An HTML editor is a program for editing HTML, the markup of a web page. Although the HTML markup in a web page can be controlled with any text editor, specialized HTML editors can offer convenience and added functionality. For example, many HT ...
s.


Differences between Kid and Genshi

* Genshi directly interprets templates (unlike Kid, which generates Python code) * Genshi uses
XInclude XInclude is a generic mechanism for merging XML documents, by writing inclusion tags in the "main" document to automatically include other documents or parts thereof. The resulting document becomes a single composite XML Information Set. The XInclud ...
for template reuse * Genshi adds attributes Kid does not have, like py:choose * 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.


References


External links

* {{DEFAULTSORT:Genshi (Templating Language) Free system software Free software programmed in Python Python (programming language) software Scripting languages Python (programming language) libraries Template engines