Kid (Templating Language)
Encyclopedia
Kid is a simple template engine for XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

-based vocabularies written in Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

. Kid claims to have many of the best features of XSLT
XSLT
XSLT is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized by the processor in standard XML syntax or in another format,...

, TAL
Template Attribute Language
The Template Attribute Language is a templating language used to generate dynamic HTML and XML pages. Its main goal is to simplify the collaboration between programmers and designers...

, and PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

, but "with much of the limitations and complexity stamped out".

While kid was heavily hyped by the TurboGears
TurboGears
TurboGears is a Python web application framework consisting of several WSGI components such as Pylons, SQLAlchemy, Genshi and Repoze.TurboGears is designed around the model-view-controller architecture, much like Struts or Ruby on Rails, designed to make rapid web application development in Python...

 framework it looks like it's more and more replaced by Genshi
Genshi (templating language)
Genshi is a template engine for XML-based vocabularies written inPython. Genshi is used to easily insert generated output into XML-based languages, usually HTML, and reuse elements between documents...

 due to better debugging and basic XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...

support as well as better performance.

Example

Python part:

from kid import Template
template = Template(file='mytemplate.kid',
title='bar',
mylist=['1', '2', '3', '4', '5', '6']
)
print template.serialize


Template part:

xmlns:py="http://purl.org/kid/ns#">

title goes here



  • item goes here





External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK