mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/twig] BEGIN loops now work
PHPBB3-11598
This commit is contained in:
parent
15114067e6
commit
eac3c1f75c
2 changed files with 4 additions and 5 deletions
|
@ -49,7 +49,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
$code = preg_replace('#<!-- (' . implode('|', $valid_starting_tokens) . ') (not )?(\$|\.)?(?:(.*?) ?)?-->#', '{% $1 $2$4 %}', $code);
|
$code = preg_replace('#<!-- (' . implode('|', $valid_starting_tokens) . ') (not )?(\$|\.)?(?:(.*?) ?)?-->#', '{% $1 $2$4 %}', $code);
|
||||||
|
|
||||||
// Replace all of our variables, {VARNAME} or {$VARNAME}, with Twig style, {{ VARNAME }}
|
// Replace all of our variables, {VARNAME} or {$VARNAME}, with Twig style, {{ VARNAME }}
|
||||||
$code = preg_replace('#{\$?([A-Z_][A-Z_0-9]+)}#', '{{ $1 }}', $code);
|
$code = preg_replace('#{\$?([a-zA-Z0-9_\.]+)}#', '{{ $1 }}', $code);
|
||||||
//echo $code;
|
//echo $code;
|
||||||
//exit;
|
//exit;
|
||||||
return parent::tokenize($code, $filename);
|
return parent::tokenize($code, $filename);
|
||||||
|
|
|
@ -45,10 +45,9 @@ class phpbb_template_twig_node_begin extends Twig_Node
|
||||||
}
|
}
|
||||||
|
|
||||||
$compiler
|
$compiler
|
||||||
->write("if (isset(\$context['loop'])) {")
|
->write("if (isset(\$context['loop']['" . $this->getAttribute('beginName') . "'])) {")
|
||||||
->write("foreach (\$context['loop']['")
|
->write("foreach (\$context['loop']['". $this->getAttribute('beginName'). "'] as \$" . $this->getAttribute('beginName') . ") {")
|
||||||
->write($this->getAttribute('beginName'))
|
->write("\$context['". $this->getAttribute('beginName'). "'] = \$" . $this->getAttribute('beginName') . ";")
|
||||||
->write("'] as \$loops[\$nestingLevel]['i'] => \$loops[\$nestingLevel]['values']) {")
|
|
||||||
->indent()
|
->indent()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue