- Template processor
A template processor (also known as a "template engine" or a "template parser")is
software or asoftware component that is designed to combine one or more
templates with adata model to produceone or more result documents.cite book
last = Niemeyer
first = Patrick
title = Learning Java
publisher = O'Reilly
location = Sebastopol
year = 2002
isbn = 0596002858 ] cite book
last = Manolescu
first = Dragos
title = Pattern Languages of Program Design 5
publisher = Addison-Wesley Professional
location = Reading
year = 2006
isbn = 0321321944 ] cite book
last = Fowler
first = Martin
title = Patterns of Enterprise Application Architecture
publisher = Addison-Wesley
location = Boston
year = 2003
isbn = 0321127420 ] For purposes of this article, a result document is anykind of formatted output, includingdocuments ,web page s, orsource code , either in whole or in fragments.ystem elements
All template processing systems consist of at least these primary elements:
* an associated data model;
* one or more source templates;
* a processor or template engine;
* generated output in the form of result documents.Data model
This may be a relational database, a source file such as
XML , an alternate format offlat file database , aspreadsheet or any of other various sources of preformatted data. Some template processing systems are limited in the types of data that can be used. Others are designed for maximum flexibility and allow many different types of data..ource template
Source templates are traditionally specified:
* according to a pre-existing programming language;
* according to a specially-defined template language;
* according to the features of a hosting software application; or
* according to a hybrid combination of some or all of the above.Template engine
The template engine is responsible for:
* connecting to the data model;
* processing the code specified in the source templates; and
* directing the output to a specific pipeline,text file , or streamAdditionally some template engines allow additional configuration options.
Result documents
These may consist of an entire document or a document fragment.
Uses
Template processing is used in various contexts for different purposes. The specific purpose is ordinarily contingent upon the
software application or template engine in use. However, the flexibility of template processing systems often enables unconventional uses for purposes not originally intended by the original designers.Template engine
A template engine is a specific kind of template processing module that exhibits all of the major features of a modern
programming language . The term "template engine" evolved as a generalized description of programming languages whose primary or exclusive purpose was to process templates and data to output text. The use of this term is most notably applied toweb development using aweb template system , and it is also applied to other contexts as well.(see e.g., Velocity, TemplateToolkit, Freemarker).]Document generation
Document generation frameworks typically use template processing as the central model for generating documents.
ource code generation
Source code generation tools support generation of
source code (as the result documents) from abstract data models (e.g., UML, relational data, domain-specific enterprise data stores) for particular application domains, particular organizations, or in simplifying the production process forcomputer programmer s.oftware functionality
A web template engine processes web templates and source data (typically from a
relational database ) to produce one or more outputweb page s or page fragments. It is ordinarily included as a part of aweb template system orapplication framework . Currently, template processing software is most frequently used in the context of development for theweb .Comparison
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 , Python,PHP , Ruby, C, and Java support template processing either natively, or through add-on libraries and modules.JavaServer Pages ,JavaServer Pages is a technology released by Sun for use with the Java programming language.cite web
url=http://java.sun.com/products/jsp/faq.html#1
title=JavaServer Pages Technology
date=2006-10-10
accessdate=2006-10-10] andActive Server Pages IDEs andrelational database management system s.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)References
ee also
*
Source code generation
*
*Chip Template Engine
* Macro preprocessor
*Preprocessor
*Domain-specific programming language External links
* [http://code.google.com/p/google-ctemplate/ CTemplate - Google, A simple but powerful template language for C++]
* [http://ctpp.havoc.ru/en/ CTPP, Crossplatform C/C++/PERL and PHP Template engine]
* [http://code.divineaspirations.net/chip Chip]
* [http://cheetahtemplate.org/ Cheetah]
* [http://www.typea.net/software/contemplate/ Contemplate]
* [http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf Enforcing Strict Model-View Separation in Template Engines]
* [http://www.kwasd.nl/expose/ Expose PHP template engine]
* [http://freemarker.org FreeMarker]
* [http://rubyforge.org/projects/galena/ Galena: Another Ruby Template Engine]
* [http://groovy.codehaus.org/Groovy+Templates Groovy Templates]
* [http://www.gvtags.org GvTags Template Engine for Groovy]
* [http://home.leetsoft.com/liquid Liquid Ruby template engine]
* [http://xtargets.com/cms/Tutorials/Matlab-Programming/MTemplate-Matlab-Code-Generation-and-Text-Templating.html Matlab template engine]
* [http://trac.php-tools.net/patTemplate/ patTemplate]
* [http://smarttemplate.sourceforge.net/ SmartTemplate]
* [http://smarty.php.net/ Smarty]
* [http://www.startonweb.com/ referencement site]
* [http://www.stringtemplate.org/ StringTemplate]
* [http://www.template-toolkit.org/ Template::Toolkit]
* [http://wiki.zope.org/ZPT/TAL/ TAL]
* [http://teng.sourceforge.net/ Teng]
* [http://www.tinybutstrong.com/ TinyButStrong]
* [http://vlib.sourceforge.net/ vLIB]
* [http://www.greaterscope.net/projects/Vemplator Vemplator]
* [http://velocity.apache.org Apache Velocity - Java Templating Engine]
* [http://maxreplace.zx6.ru/?p=2&page=about&skin=light&lang=en Мах Replace - Simple text template processor for PHP]
* Article [http://www.acceleo.org/pages/using-acceleo-with-gmf/ Using Acceleo with GMF : Generating presentations from a MindMap DSL modeler]
Wikimedia Foundation. 2010.