Architecture of a Runique Project

Tera Tags and Filters

Django-like Tags (syntactic sugar)

TagTransformed intoDescription
{% static "..." %}{{ "..." | static }} (+ integrity / crossorigin in production)Static file URL, with its SRI fingerprint outside dev
{% runique_static "..." %}same, Runique's static folderFiles Runique provides (admin, auth, js/csrf.js)
{% media "..." %}{{ "..." | media }}Media file URL
{% csrf %}{% include "csrf.html" %}Hidden CSRF field
{% messages %}{% include "message.html" %}Display flash messages
{% csp %}{% include "csp.html" %}CSP nonce attribute
{% link "name" %}{{ link(link='name') }}Named route URL
{% form.xxx %}{{ xxx | form }}Full form rendering
{% form.xxx.field %}{{ xxx | form(field='field') }}Single field rendering
{% form.xxx.js %}{{ xxx | form(field='js') }}Form JS scripts (field-by-field rendering)

The form filter declares is_safe() — its HTML is emitted unescaped, \| safe is unnecessary.


Tera Filters

FilterDescription
staticApp static URL prefix
mediaApp media URL prefix
formRender full form or specific field
csrf_fieldGenerate a hidden CSRF input
markdown, sanitizeHTML rendered from Markdown / cleaned HTML (ammonia), not escaped

Runique also registers utility filters (humanize, slugify, format_date, filesizeformat, mask, plaintext, striptags, urlencode…): see Filters.


Tera Functions

FunctionDescription
link(link='...')Named URL resolution

In context

The tags combine in a real template:

{% extends "base.html" %}

{% block content %}
  <link rel="stylesheet" href="{% static "css/contact.css" %}">

  {% messages %}

  <form method="post" action="{% link "contact" %}">
    {% form.contact_form %}
    <button type="submit">Send</button>
  </form>

  <img src="{% media avatar %}" alt="avatar">
{% endblock %}

{% static %} / {% media %} accept a string literal or a Tera variable (avatar above). See Django-like tags for the details of each tag.