Synopsis

A Jinja template is simply a text file. Jinja can generate any text-basedformat (HTML, XML, CSV, LaTeX, etc.). A Jinja template doesn’t need to have aspecific extension: .html, .xml, or any other extension is just fine.

A template contains variables and/or expressions, which get replacedwith values when a template is rendered; and tags, which control thelogic of the template. The template syntax is heavily inspired by Django andPython.

Below is a minimal template that illustrates a few basics using the defaultJinja configuration. We will cover the details later in this document:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>My Webpage</title>
  5. </head>
  6. <body>
  7. <ul id="navigation">
  8. {% for item in navigation %}
  9. <li><a href="{{ item.href }}">{{ item.caption }}</a></li>
  10. {% endfor %}
  11. </ul>
  12. <h1>My Webpage</h1>
  13. {{ a_variable }}
  14. {# a comment #}
  15. </body>
  16. </html>

The following example shows the default configuration settings. An applicationdeveloper can change the syntax configuration from {% foo %} to <% foo%>, or something similar.

There are a few kinds of delimiters. The default Jinja delimiters areconfigured as follows: