Tag

Templates

3 posts tagged Templates.

  • Twig autoescaping and the raw filter

    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.

  • Rendering Twig from Symfony Repositories Without DI

    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.

  • Extending a parent Twig block with parent()

    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.

Often tagged together with