Template Engine

Template Processor

Definition
Software designed to generate a concrete user interface from an abstract template. The template contains the components of the ui and has placeholders for the data
Template Engine

How does it work?

A template engine allows you to create a user interface free of presentation logic. All code needed to prepare the data that is to be shown is prepared separately. The template contains a declarative represention of the UI elements (for example: HTML elements), and has placeholder (for example in the form of double-curly braces {{ some_data }}) that will be replaced with part of the data.

When producing part of the UI (HTML, PDF, and others), the template engine is called to create a page, given a template and the precalculated data. It returns the UI (or part of it).

Template engines are often part of frameoworks, but a number of them can be used independently.

When should you use it?

  • Templates allow a designer to create the user interface without any knowledge or working implementation of the data model.
  • A user interface without presentation logic is easier to understand and maintain

Links