Using server-side HTML templates
Server-side HTML templates allow the backend server to dynamically generate content to send the browser content that is tailored to an individual request. Tailoring can take any form, but a typical example is to include content that is specific to the user, such as including the user’s name.
Three things are required for an HTML template: a template file that has placeholder sections into which dynamic content will be inserted, a data dictionary or context that provides the values that will determine the specific dynamic content that will be generated, and a template engine that processes the view and the dictionary to produce an HTML document into which dynamic content has been inserted, and which can be used as a response to an HTTP request, as shown in Figure 10.2.
Figure 10.2: The components of an HTML template
The task of processing a template is known as rendering and it occurs entirely in the backend server. Rendering...