umpirsky / Twig-Gettext-Extractor

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.
MIT License
113 stars 32 forks source link

PHP Fatal error: Uncaught Twig_Error_Syntax: Unknown "addslashes" filter ... #64

Open Petervw opened 5 years ago

Petervw commented 5 years ago

Using the Twig extractor we've had a fatal error on a semi-custom filter.

$twig->addFilter(new Twig_SimpleFilter('addslashes', 'addslashes'));

Our twig template:

<div>{{ content.content|raw|addslashes }}</div>

Problem: We cannot use the default sanitization from Twig, we need the raw string with real HTML characters.

This will result in the following fatal error from the extractor:

PHP Fatal error:  Uncaught Twig_Error_Syntax: Unknown "addslashes" filter
umpirsky commented 5 years ago

Thanks for reporting!

I guess we need to register that extension in https://github.com/umpirsky/Twig-Gettext-Extractor/blob/master/twig-gettext-extractor#L29-L39.

Can you try that locally and tell if it works?