Skip to main content
Theme templates run in the application’s Twig environment, so they get its extensions on top of standard Twig.

Theme assets

filter
Resolves a theme asset to a URL: a full URL is returned unchanged, then the dev server is used when THEME_ASSETS_SERVER is set, then the Vite manifest, then /e/{theme}/assets/....
filter
Resolves an application asset through the app’s own build manifest. Themes rarely need it; use asset_url for your own files.

Translation

All nine gettext helpers are available as both functions and filters. Themes use the theme domain, so reach for the d-prefixed variants.
A plain __() in a theme looks up the application’s catalog, not yours, so your translation won’t be found and the string won’t be extracted into your catalogs.

Other functions

function
hash_hmac(algo, data, key). Used for identity verification in support widgets. It runs server-side, so the secret stays out of the page.
function
locale_script(code) returns the URL of the browser translation catalog for a language, or null. Include it when your JavaScript needs translated strings.
function
template(string, name = null, strict = false) compiles a string into a template. It’s how administrator-supplied markup is rendered; strict variables are disabled, and unparsable input falls back to being printed verbatim.

Tests

test
True when an object’s class is marked as built into the application, which the admin templates use to distinguish bundled integrations from plugin-provided ones.

Extensions inherited from Twig

Globals

See Template objects for the full shape of each object.
env exposes the application’s environment variables, including database credentials and secret keys. Read one specific key when you must, such as env.THEME_ASSETS_SERVER, and never print or serialize the whole object.

Namespaces

Strict variables

With DEBUG=true, Twig raises an error for undefined variables. Guard optional values with is defined or |default(...), and test your theme in debug mode before release.