Template processor

From Wikipedia, the free encyclopedia

A diagram illustrating all of the basic elements and processing flow of a template engine.
A diagram illustrating all of the basic elements and processing flow of a template engine.

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 produce one or more result documents. For purposes of this article, a result document is any kind of formatted output, including documents, web pages, or source code, either in whole or in fragments.

Contents

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.

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 can be used. Others are designed for maximum flexibility and allow many different types of data.

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.

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.

These may consist of an entire document or a document fragment.

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.

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.[1]

Document generation frameworks typically use template processing as the central model for generating documents.

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.

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.

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, Ruby, C, and Java support template processing either natively, or through add-on libraries and modules. JavaServer Pages,[2] and Active Server Pages[3] are examples of template engines designed specifically for web application development.

Moreover, template processing is sometimes included as a sub-feature of software packages like text editors, IDEs and relational database management systems.

  • 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)

  1. ^ (see e.g., Velocity, TemplateToolkit, Freemarker).
  2. ^ JavaServer Pages is a technology released by Sun for use with the Java programming language. JavaServer Pages Technology (2006-10-10). Retrieved on 2006-10-10.
  3. ^ ASP 1.0 was originally released for use with Microsoft VBScript and JScript. It was an extension to Microsoft IIS. References to ASP 1.0, JScript, and VBScript.

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.