AGENTS
August 7, 2026 · View on GitHub
Read root AGENTS.md first. Security: SECURITY.md.
Purpose
HTML (and fragments) only. Twig under app/views/. No PHP view files for new UI.
Nuances (easy to get wrong)
-
Engine: Twig is registered in
services.php. Controllers call$app->render('name', $data)which maps to Twig (.twigoptional in the name). -
Layout: extend
layout.twigfor full pages:{% extends 'layout.twig' %} {% block title %}…{% endblock %} {% block body %}…{% endblock %} -
Globals available:
csp_nonce,app_env,base_url(from services). Prefer these over hardcoding hosts. -
Escaping: Twig escapes by default. Do not use
|rawunless content is trusted and you accept XSS risk (see SECURITY.md). -
No business logic: no DB calls, no
$_ENV, no Flight facades in templates. Pass data from the controller. -
Links:
{{ base_url }}posts— Twig global is always normalized with a trailing slash (Config::baseUrl()), so/or/myappboth join correctly. -
CSP: if you add inline
<script>or<style>, attachnonce="{{ csp_nonce }}"and keepSecurityHeadersMiddlewarein mind. -
Cache: production uses
app/cache/twig; debug disables cache. Do not commit compiled cache artifacts. -
Partials: use
{% include %}/{% embed %}; keep names clear (posts/_row.twig). -
JSON APIs do not use Twig — controllers return
$app->json(...).
Do not
- Add Latte, Blade, or raw PHP templates as a second system.
- Put secrets or env dumps in templates for “debugging” on shared environments.
- Disable autoescape globally.