Symfony: Rendering a TWIG template without headers for special template output

Rendering a TWIG template without a header in Symfony is a task you’ll end up doing in your projects. You may also capture TWIG renders into strings before they get sent to the screen. If you render templates normally with the “render” method, you’ll see the headers output to your screen like so:

It’s as easy as changing “render()” to “renderView()”, this tells Symfony to skip the headers. This is handy:

Aaron Belchamber has written 247 articles

Leave a Reply

Your email address will not be published. Required fields are marked *