Skip to content

Twig yields an escaped string and treats a missing variable as empty

The rule

Normative: this is the rule
  1. A Twig template MUST produce a string.
  2. The string MUST be HTML-escaped unless the value is piped through raw.
  3. A variable absent from the context MUST render as the empty string rather than failing.
  4. A template that cannot be compiled, and a template that fails while rendering, MUST both fail with an error saying which of the two occurred.

Why

Recorded under OPEN-25.

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · LANG-7 · changed in spec 1.0