- Template engine (web)
A (web) template engine is software that is designed to process
web template s and "content information" to produce outputweb document s. It runs in the context of a template system.pecific types of template engines
"Template engine" is ordinarily included as a part of a
web template system orapplication framework , and may be used also aspreprocessor , filter, ortemplate processor . Currently, template processing software is most frequently used in the context of development for theweb .XSLT is a template processing model designed byW3C . It is designed primarily for transformations onXML data (intoweb document s or other output).Programming languages such asPerl , Ruby, C, and Java support template processing either natively, or through add-on libraries and modules.JavaServer Pages (JSP),PHP , andActive Server Pages (ASP with VBScript, JScript or other languages) are examples, themselves, of "web template engines".Typical Features
Template engines typically include features common to most high-level
programming languages , with an emphasis on features for processingplain text .Such features include:
*variables and functions
*text replacement
*file inclusion (ortransclusion )
*conditional evaluation and loopsA web template example
The accompanying illustration depicts a simplified processing model for a typical web template engine. The template engine produces a web page by processing the web template source file along with data from a
relational database . The template engine replaces variables with specific values. In the illustration, substitution of$X
by the database content (in page 01 "Mother", on page 02 "World").A
web template might look like this:
With additional template source code ...Hello {$X}
... or, when specifying the relational database context:templateAssign ('X', 'World'); $data [01] ='Mother'; $data [02] ='World';templateAssign('X', $data [$i] ); Benefits of using template engines
* encourages organization of source code into operationally-distinct layers (see e.g., MVC)
* enhances productivity by reducing unnecessary reproduction of effort
* enhances teamwork by allowing separation of work based on skill-set (e.g., artistic vs. technical)= Comparison of template engines =
The following table lists the various template engines discussed on Wikipedia and a brief rundown of their features. The content here is a work-in-progress.
ee also
*
Template processor
*Layout engine
*
* Macro preprocessor
*Preprocessor
*Smarty (PHP: Template engine)
*Mytemplate (PHP: MyTemplate engine)
*vlibTemplate (PHP: Template engine)
*Jasper framework
*Virtual machine
*Bytecode External links
Other template engines on template systems:
* [http://2006.rmll.info/conf_423 Acceleo - MDA template based Code generator based on Eclipse and EMF]
* [http://sourceforge.net/projects/blitz-templates Blitz templates (PHP-module, written in C, very fast, OO, MVC)] , [http://alexeyrybak.com/blitz/blitz_en.html documentation] . Probably the fastest engine for PHP, [http://alexeyrybak.com/blitz/lebowski-bench-big.gifsee benchmarks] , [http://www.kmit.sk/~smok/#mystuff Simple Blitz tutorial]
* [http://beilpuz.get-mike.de Beilpuz (PHP 5)]
* [http://ctpp.havoc.ru/en/ CT++ Crossplatform C/C++/Perl and PHP Template engine]
* [http://code.divineaspirations.net/chip Chip]
* [http://www.typea.net/software/contemplate/ Contemplate]
* [http://dwoo.org/ Dwoo (PHP 5, mostly Smarty compatible)]
* [http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf Enforcing Strict Model-View Separation in Template Engines]
* [http://evoque.gizmojo.org Evoque Templating] - sandbox-able, lightweight, [http://evoque.gizmojo.org/benchmark/ fast] text templating for Python, with automaticCross-site scripting protection
* [http://rubyforge.org/projects/galena/ Galena: Another Ruby Template Engine]
* [http://www.liquidmarkup.org/ Liquid Ruby template engine]
* [http://xtargets.com/cms/Tutorials/Matlab-Programming/MTemplate-Matlab-Code-Generation-and-Text-Templating.html Matlab template engine]
* [http://www.freemarker.org FreeMarker]
* [http://pear.php.net/package/HTML_Template_IT HTML_Template_IT]
* [http://outline.mindplay.dk Outline] - PHP template engine, borrows from Smarty and PHP syntax - very small footprint
* [http://trac.php-tools.net/patTemplate/ patTemplate]
* [http://sourceforge.net/projects/php-templates php_templates (PHP-module, written in C, very fast)]
* [http://smarttemplate.sourceforge.net/ SmartTemplate]
* [http://smarty.php.net/ Smarty]
* [http://www.startonweb.com/ startonweb]
* [http://www.stringtemplate.org/ StringTemplate]
* [http://www.template-toolkit.org/ Template::Toolkit]
* [http://search.cpan.org/~rhandom/Template-Alloy-1.008/ Template::Alloy]
* [http://templatelite.sourceforge.net/ Template Lite]
* [http://www.tinybutstrong.com/ TinyButStrong]
* [http://vlib.clausvb.de/ vLIB]
* [http://www.greaterscope.net/projects/Vemplator Vemplator]Template engine usage:
* [http://g-rossolini.developpez.com/comparatifs/php/templates/ How to use the main PHP template engines, and a comparison chart (French)]
Wikimedia Foundation. 2010.