20 | | '''Genshi''' is a Python library that provides an integrated set of components for parsing, generating, and processing HTML, XML or other textual content for output generation on the web. The major feature is a [wiki:Documentation/xml-templates.html template language], which is heavily inspired by [http://kid-templating.org/ Kid]. |
| 20 | '''Genshi''' is a Python library that provides an integrated set of components for parsing, generating, and processing HTML, XML or other textual content for output generation on the web. |
| 21 | |
| 22 | The main feature is a [wiki:Documentation/xml-templates.html template language] that is smart about markup: unlike conventional template language that only deal with bytes and (if you're lucky) characters, Genshi knows the difference between tags, attributes, and actual text nodes, and uses that knowledge to your advantage. For example: |
| 23 | * Intelligent automatic escaping greatly reduces the risk of cross-site scripting attacks. |
| 24 | * [wiki:Documentation/xml-templates.html#template-directives Template directives] are often less verbose than those in most other template languages, as they can be attached directly to the elements they act upon. |
| 25 | * [wiki:Documentation/streams.html#serialization Independence of a specific serialization format] lets you instantly switch between generating well-formed HTML 4.01 and XHTML 1.0 (or other formats). |
| 26 | * [wiki:Documentation/filters.html Stream-based filtering] allows you to apply various transformations as a template is being processed, without having to parse and serialize the output again. |
| 27 | * [wiki:Documentation/xml-templates.html#id5 Match templates] let you enforce a common structure (and more) on template output. This is used instead of the more rigid inheritance feature commonly found in other template languages. |
| 28 | |
| 29 | For those cases where you don't want to generate markup, Genshi also provides a simple [wiki:Documentation/text-templates.html text-based template language]. |