[feature/twig] Add addslashes filter (to use on LA_ instead of escape)

To match previous parser behavior

PHPBB3-11598
This commit is contained in:
Nathaniel Guse 2013-07-01 10:17:58 -05:00
parent 8d3fd1fcdd
commit 42e3a4bfb9
2 changed files with 3 additions and 2 deletions

View file

@ -57,6 +57,7 @@ class phpbb_template_twig_extension extends Twig_Extension
{ {
return array( return array(
new Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), new Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),
new Twig_SimpleFilter('addslashes', 'addslashes'),
); );
} }

View file

@ -62,8 +62,8 @@ class phpbb_template_twig_lexer extends Twig_Lexer
// Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }} // Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }}
$code = preg_replace('#{L_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\') }}', $code); $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\') }}', $code);
// Replace all of our JS escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|escape('js') }} // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|addslashes }}
$code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\')|escape(\'js\') }}', $code); $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\')|addslashes }}', $code);
// Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }}
$code = preg_replace('#{([a-zA-Z0-9_\.]+)}#', '{{ $1 }}', $code); $code = preg_replace('#{([a-zA-Z0-9_\.]+)}#', '{{ $1 }}', $code);