Skip to content
BENIBIX Learn

Template Engine

Development🌐 Web DevelopmentFrameworks

Also known as Template, HTML Template, Templating

A tool that fills blanks in a page with real data to make HTML.

Think of it like

Think of it like a birthday card with a blank for the name. You fill in a new name for each friend.

Example

Emma's shop has one product template. The engine fills it with each product's name and price to make 500 pages.

Why it matters

Templates keep page layout and data apart. One template can make thousands of pages.

Definition

A template engine fills in blanks in a page with real data to make HTML. You write the page once with markers, like {{ name }}, where the data should go. When a request comes in, the engine swaps each marker for a value. Templates can also loop over lists and show parts only when a rule is true. They are common in server frameworks and static site tools.

Example code

jinja
<h1>Hi {{ name }}</h1>
<!-- with name = "Emma" this becomes: <h1>Hi Emma</h1> -->
The marker is swapped for the real name.

Common mistake

Turning off the engine's escaping to show raw HTML from users. It lets attackers put scripts on your page.

Key takeaways

  1. 1
    Blanks and data. Markers become real values.
  2. 2
    Loops and checks. Lists and optional parts.
  3. 3
    Escape by default. Keeps user text safe.