Web template system


A web template system in web publishing lets web designers and developers work with web templates to automatically generate custom web pages, such as the results from a search. This reuses static web page elements while defining dynamic elements based on web request parameters.
Web templates support static content, providing basic structure and appearance. Developers can implement templates from content management systems, web application frameworks, and HTML editors.

Overview

A web template system is composed of the following:
The template and content resources are processed and combined by the template engine to mass-produce web documents. For purposes of this article, web documents include any of various output formats for transmission over the web via HTTP, or another Internet protocol.

Motivations and typical uses

Applications

Web developers can use templates from any individual or organization to set up a website. Once they purchase or download a template, they replace all generic information in the web template with their personal, organizational, or product information. Templates are commonly used to:
Various agencies and organizations use web template systems to mass-produce content when slower production methods are less feasible.
For an introductory overview, take a news website as an example. Consider a "static website", where all web pages are static, built by a web designer. It would be very repetitive work to change individual pages as often as the news changes. A typical strategy to automate the web designer's "repetitive work" using templates could be as follows:
  1. choose a web template system to maintain the website;
  2. group news items with different presentation needs;
  3. specify the "presentation standards" through web templates, for each group of news;
  4. specify a content resource to generate or update the content of each news item.

    Style standardization

Separation of concerns

A common goal among experienced web developers is to develop and deploy applications that are flexible and easily maintainable. An important consideration in reaching this goal is the separation of business logic from presentation logic. Developers use web template systems to maintain this separation.
For the web designer, when each web page comes from a web template, they can think about a modular web page structured with components that can be modified independently of each other. These components may include a header, footer, global navigation bar, local navigation bar and content such as articles, images, videos etc.
For programmers the template language offers a more restricted logic, only for presentation adaptations and decisions, not for complex algorithms.
For other members of the "site team", a template system frees webmasters to focus on technical maintenance, content suppliers to focus on content, and gives all of them more reliability.
Moreover, it has the following advantages to its use:
One difficulty in evaluating separation of concerns is the lack of well-defined formalisms to measure when and how well it is actually met. There are, however, fairly standard heuristics that have been borrowed from the domain of software engineering. These include 'inheritance' ; and 'templating and generative programming',. The precise difference between the various guidelines is subject to some debate, and some aspects of the different guidelines share a degree of similarity.

Flexible presentation

One major rationale behind "effective separation" is the need for maximum flexibility in the code and resources dedicated to the presentation logic. Client demands, changing customer preferences and desire to present a "fresh face" for pre-existing content often result in the need to dramatically modify the public appearance of web content without disrupting the underlying infrastructure as little as possible.
The distinction between "presentation" and "business logic" is important, because:
Not all potential web template users can hire developers to design a system. Additionally, some may wish to use the Web but have little technical proficiency. Thus, a number of developers and vendors have released web templates specifically for non-technical people to use. Web template reusability is also important for even highly skilled and technically experienced developers—but it is especially critical to those who rely on simplicity and "ready-made" web solutions.
Such "ready-made" web templates are sometimes free, and easily made by an individual domestically. However, specialized web templates are sometimes sold online. Although there are numerous commercial sites that offer web templates for a licensing fee, there are also free and "open-source" sources as well.

Example

With the model typically held in a relational database, the remaining components of the MVC architecture are the control and view.
In the simplest of systems these two are not separated. However, adapting the separation of concerns principle one can completely decouple the relationships.
For example, the view template may look like this:



Sites




Then, the control template loads the view, and then uses xpath addressing to insert components from a database, for instance:

$doc = new DOMDocument;
$doc->preserveWhiteSpace = false;
$doc->Load;
$titlenode = $doc->createTextNode;
$xpath = new DOMXPath;
$xpath->registerNamespace;
$query = "//h:*/comment";
$entries = $xpath->query;
foreach
echo $doc->saveXML;
?>

Kinds of template systems

A web browser and web server are a client–server architecture. Sites often also use a web cache to improve performance. Five templating system types are classified based on when they replace placeholders with real content and assemble pages.
Template languages may be:
The source code of the template engine can be proprietary or open source.
Many template systems are a component of a larger programming platform or framework. They are referred to as the "platform's template system". Some template systems have the option of substituting a different template language or engine.
Programming languages such as Perl, Ruby, C, and Java support template processing either natively, or through add-on libraries and modules. JavaServer Pages, PHP, and Active Server Pages are examples, themselves, of web template engines. These technologies are typically used in server-side templating systems, but could be adapted for use on a "edge-side" proxy or for static page generation.

Static site generators

s often use web template systems to produce only static web pages. These can be viewed as a ready-made web design, used to mass-produce "cookie-cutter" websites for rapid deployment. They also commonly include themes in place of CSS styles. In general, the template language is used only with the editor's software.
FrontPage and Dreamweaver were once the most popular editors with template sub-systems. A Flash web template uses Macromedia Flash to create visually interactive sites.
System label/namePlatform/editorNotes
DreamweaverMacromediaHTML authoring. Embedded iterable language.
ContributeMacromediaClient authoring.
FlashMacromediaFlash authoring.
FrontPageMicrosoftHTML authoring. Embedded iterable language.
NvuLinux/NvuHTML authoring.
PelicanAn open-source communitySupports Markdown or reStructuredText. Written in Python.
Website Meta LanguageUnix-like

Many server-side template systems have an option to publish output pages on the server, where the published pages are static. This is common on content management systems, like Vignette, but is not considered out-server generation. In the majority of cases, this "publish option" doesn't interfere with the template system, and it can be made by external software, as Wget.

Server-side systems

People began to use server-side dynamic pages generated from templates with pre-existent software adapted for this task. This early software was the preprocessors and macro languages, adapted for the web use, running on CGI. Next, a simple but relevant technology was the direct execution made on extension modules, started with SSI.
Many template systems are typically used as server-side template systems:
System label/namePlatform/frameworkNotes
BladePHPPublic. Part of Laravel
CheetahTemplatePythonPublic. Embedded complex language.
DjangoPythonUse the "Django template language".
FreeMarkerJavaPublic.
FaceletsJava EEPublic. Part of JavaServer Faces
GenshiPythonPublic
HamlRuby or OtherPublic.
HamletsJavaPublic.
Jinja2PythonPublic. Embedded complex language.
KidPython
LassoProprietary. Interpreted Programming Language and Server
MustacheActionScript, C++, Clojure, CoffeeScript, ColdFusion, D, Erlang, Fantom, Go, Java, server-side JavaScript, Lua,.NET, Objective-C, ooc, Perl, PHP, Python, Ruby, Scala, TclPublic.
Basic Server Side Includes The basic directives fix a "standard".Embedded simple language, if exclude exec directive.
SmartyPHPPublic. Embedded complex language.
Template ToolkitPerlPublic. Embedded complex language.
Template Attribute Language Zope, Python, Java, Perl, PHP, XSLTPublic; a.k.a. Zope Page Templates ; see also TAL Expression Syntax, Macro Expansion TAL
TilesJavaPublic. Supports multiple template languages from various frameworks.
ThymeleafJavaPublic.
TopsitePythonPublic. "As of 2008-02-20, this project is no longer under active development."
TwigPHP
PHPlibPHPlibPublic. Embedded iterable language.
WebMacroJavaPublic. Embedded iterable language.
WebObjectsJavaUse the WebObjects Builder as engine.
Velocity JavaPublic. Use VTL - .
VignetteProprietary.Commercial solution. Embedded complex language.
VlibTemplatePHPPublic.
XSLT Any with an XSLT parserStandard. Event-driven programmable language.
XQuery Any with an XQuery parserStandard. Embedded programmable language.

Technically, the methodology of embedding programming languages within HTML, used in many "server-side included script languages" are also templates. All of them are Embedded complex languages.
System label/nameNotes
Active Server Pages Proprietary. See also: VBScript, Javascript, PerlScript, etc. extensions for ASP.
eRubyPublic.
ColdFusion Markup Language Public. Proprietary.
JavaServer Pages Public, Java platform.
Active PerlPublic.
PHPPublic.
OpenACSPublic.

There are also preprocessors used as server-side template engines. Examples:
PreprocessorNotes
C preprocessorPublic. Embedded iterable language.
M4Public. Embedded complex language.

Edge-side systems

Edge-Side template and inclusion systems. "Edge-side" refers to web servers that reside in the space between the client and the originating server. They are often referred to as "reverse-proxy" servers. These servers are generally tasked with reducing the load and traffic on originating servers by caching content such as images and page fragments, and delivering this to the browser in an efficient manner.
Basic Edge Side Includes is an SSI-like language. ESI has been implemented for content delivery networks. The ESI template language may also be implemented in web browsers using JavaScript and Ajax, or via a browser "plug-in".

Client-side systems

Many web browsers can apply an XSLT stylesheet to XML data that transforms the data into an XHTML document, thereby providing template functionality in the browser itself.

Other systems implement template functionality in the browser using JavaScript or another client-side scripting language, including:
*
The most simple form is transclusions. In other cases dynamic web pages are needed.
Examples: