aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig/node/define.php
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2013-06-29 11:07:10 -0500
committerNathaniel Guse <nathaniel.guse@gmail.com>2013-06-29 11:07:10 -0500
commit64963b5962d9a4bf1888dd1642a32ba3f6037258 (patch)
tree005b45fe8b8aab32e69ca3a7e951fc25bf70837d /phpBB/includes/template/twig/node/define.php
parentabb7901edb61e551b5783254579fef737f6f5c37 (diff)
downloadforums-64963b5962d9a4bf1888dd1642a32ba3f6037258.tar
forums-64963b5962d9a4bf1888dd1642a32ba3f6037258.tar.gz
forums-64963b5962d9a4bf1888dd1642a32ba3f6037258.tar.bz2
forums-64963b5962d9a4bf1888dd1642a32ba3f6037258.tar.xz
forums-64963b5962d9a4bf1888dd1642a32ba3f6037258.zip
[feature/twig] Fixing DEFINE statements
PHPBB3-11598
Diffstat (limited to 'phpBB/includes/template/twig/node/define.php')
-rw-r--r--phpBB/includes/template/twig/node/define.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/phpBB/includes/template/twig/node/define.php b/phpBB/includes/template/twig/node/define.php
new file mode 100644
index 0000000000..ef7565d27d
--- /dev/null
+++ b/phpBB/includes/template/twig/node/define.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2013 phpBB Group, sections (c) 2009 Fabien Potencier, Armin Ronacher
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_template_twig_node_define extends Twig_Node
+{
+ public function __construct($capture, Twig_NodeInterface $name, Twig_NodeInterface $value, $lineno, $tag = null)
+ {
+ parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ if ($this->getAttribute('capture')) {
+ $compiler
+ ->write("ob_start();\n")
+ ->subcompile($this->getNode('value'))
+ ;
+
+ $compiler->raw(" = ('' === \$value = ob_get_clean()) ? '' : new Twig_Markup(\$value, \$this->env->getCharset())");
+ }
+ else
+ {
+ $compiler
+ ->write("\$value = '")
+ ->raw($this->getNode('value')->getAttribute('value'))
+ ->raw("';\n")
+ ;
+ }
+
+ $compiler
+ ->raw("\$context['definition']->set('")
+ ->raw($this->getNode('name')->getAttribute('name'))
+ ->raw("', \$value);\n")
+ ;
+ }
+}