1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/11701] Fix loops var check

PHPBB3-11701
This commit is contained in:
Nathaniel Guse
2013-07-14 14:10:11 -05:00
committed by Nathan Guse
parent 0d31420ae0
commit c0b9db1c62
8 changed files with 60 additions and 56 deletions

View File

@@ -200,8 +200,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer
$subset = '|subset(' . $subset . ')';
}
$parent = ($parent) ?: 'loops.';
// Turn into a Twig for loop
return "{% for {$name} in loops.{$parent}{$name}{$subset} %}{$body}{% endfor %}";
return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}";
};
// Replace <!-- BEGINELSE --> correctly, only needs to be done once
@@ -224,7 +225,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer
// Replace $TEST with definition.TEST
$inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner);
// Replace .test with test|length
// Replace .foo with loops.foo|length
$inner = preg_replace('#\s\.([a-zA-Z_0-9]+)#', ' loops.$1|length', $inner);
// Replace .foo.bar with foo.bar|length
$inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner);
return "<!-- {$matches[1]}IF{$inner}-->";