Web template system

From Wikipedia, the free encyclopedia

A web template system is a kind of "View subsystem" in a Model-View-Controller (MVC or similar) design pattern, to separate presentation from content, on web document production. It is a web development tool present in Content management systems, Software frameworks, HTML editors, and many Web applications.

The basic process on the system: content (from database), and "presentation specifications" (from web template), producing (through the template engine) web pages.
Enlarge
The basic process on the system: content (from database), and "presentation specifications" (from web template), producing (through the template engine) web pages.

A web template system is characterized by (parts):

The basic process (pictured) shows how to put all together: content and web template are processed by the template engine to produce web documents.

Contents

[edit] Motivations and typical uses

For an introductory overview, a news website is used as example. Suppose a "static website", where all web pages are static, and build by a web designer, that need to add and update pages every day.
A typical strategy to automate the web-designer's "repetitive work" is:

  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.

[edit] Style standardization

Websites often require regular content updates, and standardization of appearance. Without a uniform style to browsing and to see different kinds of contents, the reader may be feel lost in the website. Style standardization also is a part of the identity of the website.

The news website example needs to be updated daily. Each news item will be contextualized by a standard presentation (page layout, structure, etc.). The template system automate this standardization and:

  • Creates consistency across the site (fonts, navigation, etc.), through the automated use of style sheets, navigation bars, etc.
  • Structures pages in a modular, industry-standard fashion familiar to Web users.
  • Improves branding, navigation, and search.
  • Frees webmasters and web designers to focus on site maintenance and content.

[edit] Separation of concerns

The idea behind the "template method" is to separate content (data) from presentation (data representation), and to separate business-logic from presentation-logic.

For the web designer, when each web page comes from a web template, he/she think on 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 well.

For programmers the template language offer a more restricted logic, only to do presentation adaptations and decisions, and not for do complex (business model) algorithms.

For another people of the "site team", template system frees webmasters to focus on technical maintenance, content suppliers to focus on content, and for all of them more reliability.

Resuming, it have many advantages in using:

  • Ease of design change: presentation variations on templates are "content invariant", web designer can update presentation without another preoccupations.
  • Ease of interface localization: menus and other presentation standards are ease to uniformize, for users browsign on the site.
  • Possibility to work separately on design and code by different people at one and the same time.

[edit] Massive production

[edit] Kinds of template systems

There are many public software and commercial packages promoted as being web templates and template engines, but there are a high diversity of disperse kinds of solutions. To select and group then in a systematic way, the first step is to characterize them as template systems.

A second step is to group and identify main properties of each characterized system:

[edit] Formal characterization

Elements (C,T,P,R) on the dataflow representation.
Enlarge
Elements (C,T,P,R) on the dataflow representation.

What can be, precisely, a web template? For a formal (but not rigorous) definition we can modeling the template system as a dataflow:

  • Input data stores:
    • Template, T   (or T1, T2, … Ti)
    • Content, C   (or C1, C2, …, Cj)
  • Process, P, and "sub-template process" P'
  • Process output, R=P(T,C) and R is a web document.

Let:

  • C0, T0, R0: the empty content, empty (ø) template and empty document.
  • T1: a template without instructions.
  • T1, T2 are "presentation variants".
  • Tlib: is a sub-template's library.
  • I(X) = "information content set" function, like a set of words from a txt converter.

Basic properties (for all T, T1, T2, T1, C, C1, C2), that web template systems must satisfy:

# Property Notes
1 P(ø,C) = ø ø bypass and R0=T0 equivalence.
2 P(T1,ø) = P(T1, C) = T1 Content independence on the "no instructions template". T1 bypass.
3 P(P(T,C1),C2) = P(T,C1) R can't used as general template T, but R can be used as T1 (Rk=T1k).
4 I(P(T,C)) \subseteq I(T) U I(C) No information generated by P. Idem for P'.
5 I(P(T1,C))=I(P(T2,C)) Content conservation on "presentation variats". Obs: imply I(T1)=I(T2). Idem for P'.
6 P(P'(T, Tlib),C) = P(T',C) Sub-template reference expansion. P' expand sub-templates references, mapping T to the expanded template T' over Tlib.

Notes:

  • The equal symbol (property column) is about a equivalence class that ignore hook cleaning.
  • Template systems modeled as complex dataflows, must use simplifier hypothesis to the characterization.
  • A sub-template recurrence, or a P pipeline, is possible if the content, C, and output (from P or P') are on the same format, like XML. Examples: see sub-templates recurrence on XQuery and explicit pipeline on Cocoon.
  • For formalization considerations and feature descriptions, suppose for P' a lazy (call by macro) evaluation.

Important conclusions from definitions:

  • The simplest "substitution string system" can characterized as template system.
  • Files from languages like XSLT or XQuery are templates, but files like a Perl script, that need a instruction like print (that is not a hook), are not. Also source code, about a documentation generator, is not a template.
  • The process can not be arbritrary.
  • If no content on template, I(T)=ø, and template language is regular, then T is like a schema.
  • Recurrence is not a "obligatory characteristic", it is only a "optional" language feature.

[edit] Outside server systems

Outside server template system architecture.
Enlarge
Outside server template system architecture.

Web template on this context produce only static web pages, and can viewed as a ready-made web design, used to mass-produce "cookie cutter" websites for rapid deployment.

HTML editors are the tipical systems using outside server subsystems. They also commonly include themes in place of CSS styles. In general the template language is to be used only with the editor's software.

FrontPage and Dreamweaver are the most popular editors with template sub-system. On Dreamweaver the template tool may also include a graphical template making it easy to edit or customise graphics and images. A Flash web template uses Macromedia Flash to create visually appealing sites.

System label/name Platform/editor Notes
BlueFish?  ?  ?
Nvu Linux/Nvu HTML authoring.
Flash Macromedia Flash authoring.
FrontPage Microsoft HTML authoring. Embedded iterable language.
Dreamweaver Macromedia HTML authoring. Embedded iterable language.

Many server-side template systems have the option to publish the output pages on the server, them the published pages be static. It is a commom feature on content management systems, like Vignette. But this does not have to be considered a out-server generation.

In the majority of the cases, this "publish option" not interferes with the template system, and it can be made by external software, as Wget.

[edit] Server-side systems

Server-side template system.
Enlarge
Server-side template system.

Server-side dynamic pages began generated by templates with pre-existent software adaptated for this task. This early softwares 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.

A lot of template systems are typically used as server-side template systems:

System label/name Plataform/framework Notes
CheetahTemplate Python Public. Embedded complex language.
Chip PHP Public.
Django Python Use the "Django template language".
FreeMarker Java Public.
Kid Python
Lasso OmniPilot Proprietary.
Basic Server Side Includes (SSI) The basic diretives fix a "standard". Embedded simple language, if exclude exec directive.
Smarty PHP Public. Embedded complex language.
StringTemplate Python Public. Embedded iterable language.
Topsite Python Public.
PHPlib PHPlib Public. Embedded iterable language.
WebMacro Java Public. Embedded iterable language.
WebObjects Java Use the WebObjects Builder as engine.
Velocity (Jakarta/Apache) Java Public. Use VTL - Velocity Template Language.
Vignette Proprietary. Commercial solution. Embedded complex language.
VlibTemplate PHP Public.
XSLT (standard language) Any with a XSLT parser Standard. Event-driven programable language.
XQuery (standard language) Any with a XQuery parser Standard. Embedded programable language.
Zope Page Templates Zope Is a Embedded programable language implemented as a Attribute Language.

Technically, the methodology of embedding programming languages within HTML (or XML, etc.), used in many "server-side included script languages" are also templates. All of them are embedded complex languages.

System label/name Notes
Active Server Pages (ASP) Proprietary (Microsoft platform). See also: VBScript, Javascript, PerlScript, etc. extensions for ASP.
eXtensible Server Pages (Cocoon XSP) Public (Apache Cocoon). Use JSP into a Cocoon framework.
ColdFusion (CFM) Proprietary.
JavaServer Pages (JSP) Public, Java platform.
Active Perl Public.
PHP Public.

There are also preprocessors used as server-side template engines. Examples:

Preprocessor Notes
C preprocessor Public. Embedded iterable language.
M4 Public. Embedded complex language.

[edit] Distributed systems

Distributed (non-centered) template system.
Enlarge
Distributed (non-centered) template system.

The more simple form are transclusions (HTML frames). In other cases it need Dynamic web pages to run.

Examples:

 

[edit] History

Is difficult to be precise about "template system beginnings" or chronology, because it started only after the "widespread development of web pages", and there are a lot of parallel developments. Context and dates of the "web beginnings":

HTTP protocol has been in use by the Web since 1990, HTML, as standard, since 1996. The web browsers explosion started with 1993's Mosaic.

Web templates, as "web designers necessity", started with the HTML and web browsers popularization. After this, different kinds of template systems was dominated the web template scenery:

  • Outside server systems: at the middle of 1990s. The main "necessity" in this first times of the web, was for static pages production. Many independent software and HTML editors adopted a variation of static web template.
  • Server-side systems: a widespread use was after middle of 1990s.
    • The first use was able with the Common Gateway Interface (for dynamic page generation), stable in the 1993's. Perhaps the first rudimentary server-side web templates was on typical Unix web servers, for AWK (plugged on CGI) report generator, or a M4 template.
    • Server Side Includes (a primitive template system) pointed a more direct way to deal with server-side scripts, at the web servers.
    • At final 1990s and beginning 2000s, with the growing of on-line and e-commerce systems, and popularization of web portals (with your CMS), the use of server-side template systems growed and domined the "template system scenery".

The high diversity of "template languages" (as a kind of "sub-language" of the CMS or the server-side programming languages), pointed to the need for a "template standard language". The matureness of XSLT and standardization of XQuery, promises, for near future, a kind of convergence.

[edit] See also