The following table lists the various Web Template Engines used in Web template systems and a brief rundown of their features.
Engine (implementation)[a] | Languages[b] | License[c] | Variables[d] | Functions[e] | Includes[f] | Conditional inclusion[g] | Looping[h] | Evaluation (language)[i] | Assignment[j] | Errors and exceptions[k] | i18n[l] | Natural templates[m] | Inheritance[n] |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Apache Velocity | Java, C# | Apache | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | No |
ASP.NET (Microsoft) | C#, VB.NET | Proprietary | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ? |
ASP.NET (Mono) | C# | LGPL | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ? |
Laravel Blade | PHP | MIT | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No | Yes |
Latte | PHP | BSD | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No | Yes |
CheetahTemplate | Python | BSD | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | Yes |
CodeCharge Studio | Classic ASP, C#, VB.NET, PHP, Perl, Java/JSP, ColdFusion | Proprietary | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | ? |
ColdFusion | CFML, CFScript | Proprietary | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
CTPP | C, C++, Perl, PHP, Python | BSD-like | Yes | Yes | Yes | Yes | Yes | No | No | Yes | ? | ? | ? |
Django | Python | BSD-like | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | Yes |
eRuby | Ruby | GNU GPL / Ruby License | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | |
FreeMarker | Java | Apache | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
Genshi (templating language) | Python | BSD-like | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes | Yes | ? | Yes |
Go templates | Go | BSD | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No |
Haml | Ruby, PHP (WIP) | MIT | Yes | Yes | Yes | Yes | Yes | Yes (Ruby) | Yes | Yes | ? | ? | ? |
Hamlets | Java | BSD | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | ? | ? | ? |
JavaServer Pages | Java | CDDL + GNU GPL[1] | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ? |
Jinja | Python | BSD | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | No | ? | ? | ? |
Jinja2 | Python | BSD | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes | Yes | Yes | Yes |
Kid (templating language) | Python | MIT | Yes | Yes | Yes | Yes | Yes | Yes (Python) | Yes | Yes | ? | ? | ? |
Lucee | CFML | LGPL | Yes | Yes | Yes | Yes | Yes | Yes (CFML) | Yes | Yes | Yes | Yes | Yes |
Mustache | 30+ languages | MIT | Yes | Yes | Yes | Yes | Yes (foreach) | No | No | Yes | Yes | Yes | No |
Open Power Template | PHP 5 | BSD-like | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes | ? | ? | ? |
Pebble | Java | BSD-like | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
PHP | PHP | PHP License | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No |
Razor | C#, F#, VB.NET | Apache | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Smarty | PHP | LGPL | Yes | Yes | Yes | Yes | Yes | Yes (PHP) | Yes | Yes? | Yes | ? | Yes |
Squirrelly | JS | MIT | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
Template Attribute Language | Various | open source | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? |
Template Toolkit | Perl, Python | open source | Yes | Yes | Yes | Yes | Yes | Yes (Perl) | Yes | Yes | ? | ? | ? |
Thymeleaf | Java | Apache | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | No |
TinyButStrong | PHP | LGPL | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? |
Twig | PHP | BSD | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | No | Yes |
vlibTemplate | PHP | Artistic License | Yes | Yes | Yes | Yes | Yes | No | No | No | ? | ? | ? |
web2py | Python | LGPL3 | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
WebMacro | Java | Apache, GNU GPL | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | ? | ? | ? |
Engine (implementation)[a] | Languages[b] | License[c] | Variables[d] | Functions[e] | Includes[f] | Conditional inclusion[g] | Looping[h] | Evaluation (language)[i] | Assignment[j] | Errors and exceptions[k] | i18n[l] | Natural templates[m] | Inheritance[n] |
PML is a high performance template engine implemented in Python, it supports many advanced features such as template filters, output filters, and more. Pyratemp - a very small (template-engine, using restricted python-expressions. There are also some benchmarks and comparisons of different template-engines.
See also[edit]
Notes[edit]
- ^ abEngine (implementation) : engine name
- ^ abLanguages : implementation language of the engine (not the template script language)
- ^ abLicense : Software license agreement
- ^ abVariables : script language power to use variables
- ^ abFunctions : script language power to use functions
- ^ abIncludes : script language power include external files
- ^ abConditional inclusion : script language power to conditional includes
- ^ abLooping : script language power to do loops (for, while) or recursion
- ^ abEvaluation (language) : script language power to do 'eval command' (to the implementation language)
- ^ abAssignment : set names and references to sub-templates (?)
- ^ abErrors and exceptions : engine output script errors.
- ^ abi18n : Internationalization and localization feature
- ^ abNatural templates : the template can be a document as valid as the final result, the engine syntax doesn't break the document's structure
- ^ abInheritance : Supports the ability to inherit a layout from a parent template, separately overriding arbitrary sections of the parent template's content.
References[edit]
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Comparison_of_web_template_engines&oldid=916522402'
step
is a pure-Python module providing a very simple template engine withminimum syntax. It supports variable expansion, flow control and embedding ofPython code.Installation
Use pip:
or download the package from GitHub and run theinstall script:
Basic usage
A template is a string containing any kind of textual content and a set ofdirectives representing variables, control structures and blocks of Python code.
Variables are enclosed in
{{}}
and follow the same syntax rules as Pythonvariables; e.g.:Flow control expressions are written like regular Python control structures,preceded by the
%
sign and must be closed by a %end<statement>
tag; e.g.:All text between
<%
and %>
is considered Python code; you can use thebuiltin echo()
function to output some text from within Python code blocks;e.g.:You can use the special function
isdef()
to perform some actions only if aname is defined in the template namespace; e.g.:The
setopt()
function allows you to enable options that modify the templateoutput; the only supported option is 'strip', which removes leading/trailingwhitespace, contiguous whitespace and empty lines and defaults to true; e.g.:The 'strip' option can also be given as a parameter during
Template
objectcreation; e.g.:A backslash at the end of a line will suppress the newline character.
Documentation
More examples and a detailed description of the module and its classes areavailable at http://www.kernel-panic.it/programming/step/.
Tests
To run the test suite, just run
python setup.py test
.Credits
Copyright (c) 2012 Daniele Mazzocchio ([email protected]).Several improvements by Erki Suurjaak.
Licensed under the BSD license (see LICENSE.md file).