A template engine (or template parser or template processor) is software that processes input text (the template) to produce one or more output texts on a website.
Content on websites needs updating and standardization. A news website, for example, needs daily updating and each updated news item will be contextualized by a standard layout and standard page-location. A strategy to automate this standardization is:
There are so many template engine examples, and Smarty, vlibTemplate, Velocity, FreeMarker, StringTemplate are some of them. To reduce the diversity, for "simplify" the life of companies and programers, there are a important class of "complex template engines", the XSLT parsers. It is a W3C effort to reduce the diversity of the engine implementatiom methods and template languages.
Some template engines (e.g. JSP) allow complete blocks of code to be embedded into a template, which is powerful, but gets very opaque as soon as a certain complexity level is reached. Smarty allows regular expressions and complex loop structures within the template, too. On the other hand some web developers prefer to handle logic within PHP and not within the template.
Template engines can be used for advanced modular programming, too. E.g. if you want to create a complex website, a template engine will help you to create clean and structured code.
and your PHP script like that:Hello {$X}
Or, when usign in a database context (figure, where$tmpl->assign('X', 'World');
$i denote the web page identification):
$data $data[02='World'; $tmpl->assign('X', $data*);
Not every template engine uses methods like "assign". Possible names are "setvar", "merge" and so on. See vlibTemplate and TinyButStrong for more detailed examples.
Web server software | Scripting languages | Template engines
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Template engine".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world