Last Updated: February 25, 2016
·
1.426K
· rodnaph

Twig Filter Escaping

When using filters, by default Twig will automatically try and escape the output data from the last filter in a chain to match the current context (eg. 'html'). If you don't want this behaviour then you need to mark your filter as safe.

'myFilter' => new Twig_Filter_Method(
    $this,
    'myFilter',
    array('is_safe' => array('html'))
);

The end.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#php
#twig
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside