| |
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.
late engines typically include features common to most high-level programming languages, with an emphasis on features for processing plain text.
Such features include:
accompanying illustration depicts a simplified processing model for a typical web template engine.

Discussion
Ask a question about 'Template engine'
Start a new discussion about 'Template engine'
Answer questions from other users
|
Encyclopedia
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.
Typical features
Template engines typically include features common to most high-level programming languages, with an emphasis on features for processing plain text.
Such features include:
- variables and functions
- text replacement
- file inclusion (or transclusion)
- conditional evaluation and loops
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:
Hello
With additional template source code ...
templateAssign ('X', 'World');
... or, when specifying the relational database context:
$data[01]='Mother'; $data[02]='World';
templateAssign('X', $data[$i]);
Benefits
Benefits of using template engines include:
- Encouraging organization of source code into operationally-distinct layers (see e.g., MVC)
- Enhancing productivity by reducing unnecessary reproduction of effort
- Enhancing teamwork by allowing separation of work based on skill-set (e.g., artistic vs. technical)
Comparison 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.
| Engine (Implementation) | Languages | License | Platform | Variables | Functions | Includes | Conditional Inclusion | Looping | Evaluation (Language) | Assignment | Errors & Exceptions |
|---|
| StringTemplate | Java (native), Python, C# | open-source? | Cross-Platform | | | | | | | | | | ASP.net (Microsoft) | C#, VB.net | Proprietary | Microsoft Windows | | | | | | | | | | ASP.net (Mono) | C# | GNU LGPL | Cross-Platform | | | | | | | | | | Apache Velocity | Java, C# | Apache License | Cross-Platform | | | | | | | | | | | PHP 5 | GNU LGPL | Cross-Platform | | | | | | | | | | CheetahTemplate | Python | MIT License | Cross-Platform | | | | | | | | | | Chip Template Engine | PHP, Perl | open-source? | Cross-Platform | | | | | | | | | | CTPP | C, C++, Perl, PHP, Python | BSD-like | Cross-Platform | | | | | | | | | | | PHP 5 | GNU LGPL | Cross-Platform | | | | | | (PHP) | | | | Dylan Server Pages | Dylan language | unknown | unknown | | | | | ? | | | | | eRuby | Ruby | open-source? | Cross-Platform | | | | | | | | | | | Python, Py3K | AFL v3.0 | Cross-Platform | | | | | | (Python) | | | | FreeMarker | Java | BSD-like | Cross-Platform | | | | | | | | | | Genshi (templating language) | Python | BSD-like | Cross-Platform | | | | | | (Python) | | | | | Groovy | Apache License | Cross-Platform | | | | | | (Groovy) | | | | | PHP, Ruby | MIT License | Cross-Platform | | | | | | | | | | Haml | Ruby, PHP (WIP) | MIT License | Cross-Platform | | | | | | (Ruby) | | | | Hamlets | Java | BSD | Cross-Platform | | | | | | | | | | JSP Weaver | Java | Proprietary | Cross-Platform | | | | | | | | | | Jasper framework | Perl, PHP, C#, Java | open-source? | Cross-Platform | | | | | | | | | | JavaServer Pages | Java | Proprietary | Cross-Platform | | | | | | | | | | Jinja | Python | BSD | Cross-Platform | | | | | | (Python) | | | | | Python | BSD-like | Cross-Platform | | | Through inheritance | | | | | | | Kid (templating language) | Python | open-source? | Cross-Platform | | | | | | (Python) | | | | | Python | MIT | Cross-Platform | | | | | | (Python) | | | | | Python | MIT | Cross-Platform | | | | | | (Python) | ? | | | | PHP, Java, VB.net | GNU LGPL | Cross-Platform | | | | | | | | ? | | | PHP 5 | GNU GPL | Cross-Platform | | | | | | (PHP) | | ? | | Open Power Template | PHP 5 | GNU LGPL | Cross-Platform | | | | | | (PHP) | | | | | PHP 5 | open-source | Cross-Platform | | | | | | (PHP) | | ? | | PHAML | PHP | MIT License | Cross-Platform | | | | | | (PHP) | | ? | | | PHP 5 | GNU GPL | Cross-Platform | | | | | | (PHP) | | | | Smarty | PHP | GNU LGPL | Cross-Platform | | | | | | (PHP) | | ? | | TinyButStrong | PHP | open-source? | Cross-Platform | | | | | | | | | | Vemplator | PHP | MIT License | Cross-Platform | | | | | | (PHP) | | | | vlibTemplate | PHP | Artistic License | Cross-Platform | | | | | | | | | | | PHP | open-source | Cross-Platform | | | indirect | | | | | | | Template Toolkit | Perl | open-source | Cross-Platform | | | | | | (Perl) | | | | WebMacro | Java | open-source? | Cross-Platform | | | | | | | | | | | PHP 5, JavaScript | MIT License | Cross-Platform | | | | | | | | |
See also
- Category:Template engines
External links
|