- What is templating?
- Defining templates in jQuery Template
- Using simple Mustache templates with sections and conditions
- Adding conditionals and loops to Handlebars templates
- Working with Dust templates
The template engine is responsible for:
- connecting to the data model;
- processing the code specified in the source templates; and
- directing the output to a specific pipeline, text file, or stream.
Additionally some template engines allow additional configuration options. A template engine is ordinarily included as a part of a web template system or application framework, and may be used also as preprocessor or filter.
A diagram illustrating all of the basic elements and processing flow of a template engine.
A template engine is a specific kind of template processing module that exhibits all of the major features of a modern programming language. The term template engine evolved as a generalized description of programming languages whose primary or exclusive purpose was to process templates and data to output text. The use of this term is most notably applied to web development using a web template system, and it is also applied to other contexts as well.
Benefits of using template engines
- encourages organization of source code into operationally-distinct layers (see e.g., MVC)
- enhances productivity by reducing unnecessary reproduction of effort
- enhances teamwork by allowing separation of work based on skill-set (e.g., artistic vs. technical)
Templating becomes useful when the information distributed may change, is too large to be maintained in various HTML pages by available human resources and not large enough to require heavier server-side templating.
See more resources:
Build My Site
Originally published at buildmy-site.com on December 12, 2014.