Skip to main content

Designing Templates

Web templating refers to a web technology technique that defines the presentation (layout and style) of web pages with templates in various forms. These forms are then filled in by a template engine (or processor).

1.1 Definitions

“A web template is a tool used to separate content from presentation in web design, and for mass-production of web documents. It is a basic component of a web template system.  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.” 

“Templating, and in particular Web templating, involves the presentation of information in a form which is often (but not always) intended to be readable, even attractive, to a human audience. Frequently, templating solutions involve a document (the template) which may look somewhat like the final output but perhaps in a simplified or stylized form, along with some data which must be presented using that template; combining these two things produces the final output which in Web templating is usually (but not always) a Web page of some kind.” 

“HTML embedded in code is messy and difficult to maintain. It's better to use a templating system, where the HTML is kept in a separate file with special syntax to indicate where the data from the application appears.” 

1.2 Architecture of web templating systems

The basic process: content (from a database), and "presentation specifications" (in a web template), are combined (through the template engine) to mass-produce web documents.

Templating systems are very common in portalware, and particularly content management systems. All template processing systems consist of at least these primary elements:

  • an associated data model e.g. an SQL database or an XML file
  • one or more source templates, e.g. a special template language or an HTML-embedded markup
  • a processor or template engine, i.e. the program that will connect to the data, execute the instructions in the source template and produce the HTML or other format
  • generated output in the form of result documents, typically a web page.

Various template engines have different computational power. Typically, a templating language includes

  • variables and functions
  • text replacement
  • conditions and loops (to include lists of elements)
  • inclusion of files

In addition, a full templating/presentation framework may include a caching system, i.e. a mechanism that will store dynamic web pages as static pages that only will change if dynamic information did change.