Custom autostart in Symfony 2

I need to add the ability to avoid the double curly braces {{and}} to the Symfony 2 default autoloader. Therefore it should work without any changes inside the branch templates .

I tried to add a custom escaper like

$twig->getExtension('Twig_Extension_Core')->setEscaper('angular-html', $escaper);

      

and replace the default "html" sketch strategy with custom "angular-html"

class AngularEscapingStrategy
{
    public static function guess($name)
    {
        $strategy = \Twig_FileExtensionEscapingStrategy::guess($name);
        return ($strategy === 'html') ? 'angular-html' : $strategy;
    }
}

      

So this works, but the built-in twig functions like form_row or nl2br require the escaper name to be "html" to work properly:

new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),

      

Is there any other way to extend the default "html" escaper and keep its name?

+3


source to share





All Articles