البناء باستخدام واجهة
ما لا تدعمه واجهة
Read this page before porting a theme from another platform. It is the shortest route to understanding what Wajha actually is.
Wajha is Jinja-style, not Jinja-compatible
Wajha's syntax comes from the Django/Jinja family, and we describe it as Jinja-style with a published tag and filter set. We do not claim compatibility, because a theme written for a Python Jinja2 environment — or for another platform's Jinja dialect — will not run here unmodified.
The differences that catch people:
| Thing | Jinja | Wajha |
|---|---|---|
| Filter arguments | value | truncate(160) | value|truncatechars:160 — a colon, not brackets |
| Loop variables | loop.index, loop.first | forloop.Counter, forloop.First — capitalised |
| Empty loop | {% for %}…{% else %} | {% for %}…{% empty %} |
| Parent block | {{ super() }} | {{ block.Super }} — capital S (see below) |
| Your theme's strings | {{ _('key') }} or a filter | Data: {{ t.section.key }} |
| Dates | strftime-style %Y-%m-%d | Planned: named formats — see below |
| String formatting | Python %s / {} | Not available; use filters |
Line statements (# for) | Optional in Jinja2 | Not supported |
| Whitespace control | {%- … -%} and {{- … -}} | The same — both work |
{{ block.super }} in lowercase does not fail. It renders an empty string, silently, and the
parent block's content vanishes from the page. Of everything on this list it is the one most
likely to cost you an afternoon.
Not supported, deliberately
Arbitrary code
There is no {% python %}, no eval, no way to define a function. A template describes
markup; logic belongs in the settings schema or in the data the route provides.
Filesystem and network access
No {% ssi %}, no reading files, no HTTP calls. {% include %} and {% extends %} resolve
only within your own theme, and a path containing .. or a leading / fails to compile.
Disabling output escaping
Every value you print is HTML-escaped, and there is no opt-out. These are refused when your theme is loaded, with the file and line:
| Banned | Why |
|---|---|
|safe, {% autoescape %} | They switch escaping off |
{% filter %} | It applies filters to a whole block — another route to safe |
|truncatechars_html, |truncatewords_html | They return their input as unescaped HTML |
|urlize, |urlizetrunc | They generate markup, with an option to skip escaping |
The two _html truncation filters are the surprising ones: they look like text helpers, and
a product description passed through either would render raw. Use truncatechars and
truncatewords, which escape.
Merchant-authored rich text — a page body written in an editor — will be printed through a rich
filter that runs a server-side allowlist sanitiser. It arrives with the slice that introduces
rich-text content, and until then nothing in the context is rich text.
Generators and unbounded loops
There is no range(), and the {% lorem %} text generator is banned, as is {% now %} —
page timestamps come from the data. Every collection you can loop over is a bounded list the
route placed in the context. This is a deliberate limit on how much work one template can
ask for.
Arithmetic, on the other hand, is available: {{ a + b }}, {{ a / b }}. That includes
dividing a price, which is exactly why every amount arrives pre-formatted — see
Money, Dates & Numerals.
Merchant-authored HTML or JavaScript in settings
A merchant cannot type markup into a Theme Editor field and have it rendered. Settings are typed — text, number, colour, URL, image, select — and typed values are escaped on output. A "custom HTML" setting is the classic store-builder XSS hole, and on a storefront it would execute beside a shopper's payment details.
Things that are coming
These are not supported yet and are on the roadmap rather than ruled out:
- Custom filters defined by a theme.
- Server-rendered cart and checkout templates (today those are platform-rendered, with hooks for your styling).
- Theme-defined page templates beyond the fixed route set.
If you are porting
Work in this order:
- Change filter arguments from
f(x)tof:x. - Replace
loop.*withforloop.*and capitalise the field names;{% else %}on a loop becomes{% empty %};super()becomes{{ block.Super }}. - Move your strings into
locales/ar.jsonandlocales/en.jsonand read them ast.…. - Remove every
|safeand every_htmlfilter. If output looks wrong afterwards, the value was meant to be text. - Replace any price arithmetic with the
formattedfield — see Money, Dates & Numerals. - Replace physical CSS properties with logical ones — see RTL & Arabic.
- Load the theme. Anything banned, any unresolvable include and any syntax error is reported with its file and line, and the theme is refused until it is fixed.