liveBook · Manning

Template engine

As explained in Rust Servers, Services, and Apps

A template engine is a software component that combines templates with data to generate rendered output such as HTML.

A template engine combines a template file with data supplied by a web application to generate HTML. The data can be loaded on demand and tailored to the requesting user, producing a dynamic page from a reusable template. section 7.1

Figure 7.1 Server-side rendering of web pages

Shows how templates fit into server-side rendering to produce web pages. section 7.1

In a server-rendered Rust application, templates work alongside the web framework and request-handling code:

  • The application passes data to the template engine, which embeds it in the template and generates HTML. section 7.1
  • Routes and handlers process HTTP requests; handlers can render templates and return the resulting pages. section 8.4
  • Tera template variables can provide form feedback, while handlers can re-render a form with an error message. section 8.4

Tutor registration

A Tera-backed registration form can display fields for a username, password, tutor name, image URL, and profile. If submitted data has an error, the handler can render the form again with a suitable message. section 8.0 section 8.4

How Rust Servers, Services, and Apps covers it

How deep it goes
Defines template input, HTML output, and embedded data, then relates templates to routes, handlers, and persistence.
Examples
Uses a tutor-registration form with user fields and template-rendered validation feedback.
What you can do after
Apply Tera with Actix Web to render dynamic pages and forms, process submissions, and return user feedback.
How it connects
Connects server-side rendering with Tera, Actix Web, HTML forms, request handlers, routes, and database access.

Also explained in

Compare how 5 books explain template engine →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.