Template processor

Template processor

A template processor (also known as a "template engine" or a "template parser")is software or a software component that is designed to combine one or more
templates with a data 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, including documents, web pages, or source 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 of flat file database, a spreadsheet 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 stream

Additionally 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 to web development using a web 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 for computer programmers.

oftware functionality

A web template engine processes web templates and source data (typically from a relational database) to produce one or more output web pages or page fragments. It is ordinarily included as a part of a web template system or application framework. Currently, template processing software is most frequently used in the context of development for the web.

Comparison

XSLT is a template processing model designed by W3C. It is designed primarily for transformations on XML data (into web documents or other output).

Programming languages such as Perl, 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
] and Active Server PagesIDEs and relational database management systems.

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.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Template engine — may refer to any of the following:* For all uses in generating output from templates, see template processor * For use exclusively in a web template system, see template engine (web) * For use exclusively in word processing applications, see mail …   Wikipedia

  • Template engine (web) — A (web) template engine is software that is designed to process web templates and content information to produce output web documents. It runs in the context of a template system.pecific types of template engines Template engine is ordinarily… …   Wikipedia

  • Template Oriented Programming — In computer programming, Template oriented programming (TOP) is a programming paradigm that focuses on templates to accomplish a programmer’s goals. Template oriented programming is a more general version of generic programming in which the… …   Wikipedia

  • Template (word processing) — The term template, when used in the context of word processing software, refers to a sample fill in the blank document that can be completed either by hand or through an automated iterative process, such as a with a wizard. Oncethe template is… …   Wikipedia

  • XML template engine — A XML template engine (or XML template processor ) is a specialized template processor for XML input and/or output, working in a XML template system context. There are two main types: * XML suite standards compliant engines: ** XSLT engines ,… …   Wikipedia

  • Word processor — OpenOffice.org Writer in Version 3.2 …   Wikipedia

  • XSL Transformations — infobox file format name = XSL Transformations extension = .xsl, .xslt mime = application/xslt+xml [ [http://www.w3.org/TR/xslt20/#xslt mime definition XSL Transformations (XSLT) Version 2.0 ] ] owner = [http://www.w3.org/ World Wide Web… …   Wikipedia

  • Automatic programming — In computer science, the term automatic programming [Ricardo Aler Mur, [http://et.evannai.inf.uc3m.es/icml06/aiptutorial.htm Automatic Inductive Programming] , ICML 2006 Tutorial . June 2006.] identifies a type of computer programming in which… …   Wikipedia

  • Computer program — A computer program (also software, or just a program) is a sequence of instructions written to perform a specified task with a computer.[1] A computer requires programs to function, typically executing the program s instructions in a central… …   Wikipedia

  • Model–view–controller — A general representation of the MVC design pattern. Model view controller concept. The solid line represents a direct as …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”