Template engine (web)
This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (June 2008) |
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.
Types
Template engine is ordinarily included as a part of a web template system or application framework, and may be used also as preprocessor, filter, or template processor. 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 (JSP), PHP, and Active 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 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:
<html> <h1>Hello {$X}</h1> </html>
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 |
---|---|---|---|---|---|---|---|---|---|---|---|
ASP.net (Microsoft) | C#, VB.net | Proprietary | Microsoft Windows | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
ASP.net (Mono) | C# | GNU LGPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Apache Velocity | Java, C# | Apache License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Beilpuz | PHP 5 | GNU LGPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes |
CheetahTemplate | Python | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Chip Template Engine | PHP, Perl | open-source? | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | No |
csharptemplates | C# | New BSD | .NET | Yes | No | No | No | No | No | No | No |
CTPP | C, C++, Perl, PHP, Python | BSD-like | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | No | Yes |
Django | Python | BSD-like | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Dwoo | PHP 5 | BSD License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes |
Dylan Server Pages | Dylan language | unknown | unknown | Yes | Yes | Yes | Yes | No? | No | No | No |
eRuby | Ruby | open-source? | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Evoque Templating | Python, Py3K | AFL v3.0 | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | No | Yes |
FreeMarker | Java | BSD-like | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Genshi (templating language) | Python | BSD-like | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes |
Google-ctemplate | C++ | BSD License | Cross-Platform | Yes | No | Yes | Yes | Yes | No | No | No |
Grantlee Template System | C++/Qt | LGPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
GvTags | Groovy | Apache License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Groovy) | Yes | No |
H2o | PHP, Ruby | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes |
Haml | Ruby, PHP (WIP) | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Ruby) | Yes | Yes |
Hamlets | Java | BSD | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes |
JSP Weaver | Java | Proprietary | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Jasper framework | Perl, PHP, C#, Java | open-source? | Cross-Platform | Yes | No | No | No | No | No | No | No |
JavaServer Pages | Java | Proprietary | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Jenner | JavaScript | LGPL | In-Browser | Yes | Yes | No | No | Yes | Yes | Yes (if allowed by hosting application) | Yes |
Jinja | Python | BSD | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | No |
Jinja2 | Python | BSD | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes |
Kalahari | Python | BSD-like | Cross-Platform | Yes | Yes | Through inheritance | No | Yes | No | Yes | Yes |
Kid (templating language) | Python | MIT | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes |
Mako | Python | MIT | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | No |
Mars-Templater | PHP 5 | MIT License | Cross-Platform | Yes | No | No | Yes | Yes | No | No | No |
pyratemp | Python | MIT | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Python) | No? | No |
MiniTemplator | PHP, Java, VB.net | GNU LGPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | No | No? |
Template Blocks | PHP 5 | GNU GPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? |
Toupl | Any with OOP and String class support | Apache License | Cross-Platform | Yes[1] | Yes[1] | Yes[1] | Yes[1] | Yes[1] | Yes[1] | Yes[1] | Yes[1] |
Obyx | Obyx | GNU GPL | Unix/Mac OS X | Yes | Yes | Yes | Yes | Yes | Yes (Obyx) | Yes | Yes |
Open Power Template | PHP 5 | BSD-like | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes |
Outline | PHP 5 | open-source | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? |
PHAML | PHP | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? |
Phammable | PHP 5 | GNU GPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes |
PURE Unobtrusive Rendering Engine | Javascript | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Smarty | PHP | GNU LGPL | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? |
StringTemplate | Java (native), Python, C# | open-source? | Cross-Platform | Yes | No | Yes | Yes | Yes | No | No | No |
Template Attribute Language | Python, PHP 5 | open-source | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
TinyButStrong | PHP | GNU LGPL | Cross-Platform | Yes | No | Yes | No | Yes | No | No | No |
Twig | PHP | BSD | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? |
Vemplator | PHP | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | No | No |
vlibTemplate | PHP | Artistic License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | No | No |
Deihro TemplateEngine | PHP | open-source | Cross-Platform | Yes | Yes | indirect | No | No | No | No | No |
Template Toolkit | Perl,Python | open-source | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes (Perl) | Yes | Yes |
WebMacro | Java | open-source? | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
QueryTemplates | PHP 5, JavaScript | MIT License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
FastTemplate | PHP | Artistic License | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | No |
Younicycle | PHP 5, JavaScript, ActionScript | Proprietary | Cross-Platform | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes |
Notes
See also
- Bytecode
- Jasper framework
- Layout engine
- Macro preprocessor
- Mytemplate (PHP: MyTemplate engine)
- Preprocessor
- Smarty (PHP: Template engine)
- Template engines
- Template processor
- Virtual machine
- VlibTemplate (PHP: Template engine)
External links
If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...