Tag
Templates
4 posts tagged Templates.
Posts

09/27/2026
Twig strict_variables: errors or silent null
strict_variables makes Twig throw on a missing variable, attribute or method instead of using null. Symfony turns it on in dev and off in prod.

09/02/2026
Twig autoescaping and the raw filter
Autoescaping makes Twig safe by default and makes |raw the fastest way to undo that. The catch is that HTML escaping is only correct in HTML - inside a script tag or an unquoted attribute, the default is the wrong answer.

07/04/2019
Rendering a Twig template outside a controller
You do not need a controller to render Twig, and you should not pass the container around to get at it. Inject the Environment, and use createTemplate when the template itself comes from the database.

11/30/2015
Extending a parent Twig block with parent()
Define a block in a child template and it replaces the parent's version completely - which is rarely what you wanted for a block holding stylesheets or scripts. parent() puts the inherited content back.