The panel is one server-rendered system, per ADR-0001, so the engine has to turn templates into HTML.
Pages are not rendered whole every time. Hypermedia interactions swap a fragment of a page in place, so a named region of a template has to be renderable on its own.
Templates come from more than one place. Core provides them, modules provide their own, and a theme replaces any of them, so a reference has to resolve through an ordered chain of locations rather than one directory.
Module authors write templates, so the engine’s choice is one they have to work in.
Twig is the panel’s template engine. Templates are Twig templates, resolved through Twig’s own loader, and rendering goes through a Twig environment built once when the panel boots.
Other template engines. Several were weighed, though the record does not name them. Twig was chosen for its sandboxing and its flexibility, and because module authors are more likely to know it than any alternative.
Easier:
Harder:
Constrained:
created and
decided. It records Twig’s named blocks giving fragment rendering, its loader accepting several paths per
namespace so that the resolution chain needs no custom loader, module authors being more likely to know it than
any alternative, and its escaping being for HTML by default so that other contexts need an explicit filter. It
also records that templates are compiled to PHP and where the compiled output goes.