aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-06-10 11:57:51 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-06-10 11:57:51 -0500
commiteac3c1f75c370e9ddb7319db0b11c7c8fa161709 (patch)
tree77a09ec1abe0f470bee04e82b16d7dfab4fd8048 /phpBB/includes/template
parent15114067e6c88e4ec8fa9d1ff66fd0de28b1144f (diff)
downloadforums-eac3c1f75c370e9ddb7319db0b11c7c8fa161709.tar
forums-eac3c1f75c370e9ddb7319db0b11c7c8fa161709.tar.gz
forums-eac3c1f75c370e9ddb7319db0b11c7c8fa161709.tar.bz2
forums-eac3c1f75c370e9ddb7319db0b11c7c8fa161709.tar.xz
forums-eac3c1f75c370e9ddb7319db0b11c7c8fa161709.zip
[feature/twig] BEGIN loops now work
PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r--phpBB/includes/template/twig/lexer.php2
-rw-r--r--phpBB/includes/template/twig/node/begin.php7
2 files changed, 4 insertions, 5 deletions
diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php
index a880377583..4402760a7b 100644
--- a/phpBB/includes/template/twig/lexer.php
+++ b/phpBB/includes/template/twig/lexer.php
@@ -49,7 +49,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
$code = preg_replace('#<!-- (' . implode('|', $valid_starting_tokens) . ') (not )?(\$|\.)?(?:(.*?) ?)?-->#', '{% $1 $2$4 %}', $code);
// 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;
//exit;
return parent::tokenize($code, $filename);
diff --git a/phpBB/includes/template/twig/node/begin.php b/phpBB/includes/template/twig/node/begin.php
index 52e0a96f2a..1f4de9deda 100644
--- a/phpBB/includes/template/twig/node/begin.php
+++ b/phpBB/includes/template/twig/node/begin.php
@@ -45,10 +45,9 @@ class phpbb_template_twig_node_begin extends Twig_Node
}
$compiler
- ->write("if (isset(\$context['loop'])) {")
- ->write("foreach (\$context['loop']['")
- ->write($this->getAttribute('beginName'))
- ->write("'] as \$loops[\$nestingLevel]['i'] => \$loops[\$nestingLevel]['values']) {")
+ ->write("if (isset(\$context['loop']['" . $this->getAttribute('beginName') . "'])) {")
+ ->write("foreach (\$context['loop']['". $this->getAttribute('beginName'). "'] as \$" . $this->getAttribute('beginName') . ") {")
+ ->write("\$context['". $this->getAttribute('beginName'). "'] = \$" . $this->getAttribute('beginName') . ";")
->indent()
;