summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Node/Include.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-08-05 06:03:40 -0400
committerczaks <marcin@6irc.net>2013-08-05 06:03:40 -0400
commita84c4510fccfdc0cfb6f187633daea10dc70f326 (patch)
tree6077f5211196ae40cac0184bb7cc67b81d320b0b /inc/lib/Twig/Node/Include.php
parent33c7abf11f3a9b5c0964a2d7a25533c2849dbc78 (diff)
parenta8327c3a37fd22d2aa5d63061c9d3eaa30ae425a (diff)
Merge branch 'master' of github.com:vichan-devel/Tinyboard
Conflicts: js/post-hider.js
Diffstat (limited to 'inc/lib/Twig/Node/Include.php')
-rw-r--r--inc/lib/Twig/Node/Include.php45
1 files changed, 28 insertions, 17 deletions
diff --git a/inc/lib/Twig/Node/Include.php b/inc/lib/Twig/Node/Include.php
index 467749b5..ed4a3751 100644
--- a/inc/lib/Twig/Node/Include.php
+++ b/inc/lib/Twig/Node/Include.php
@@ -13,8 +13,7 @@
/**
* Represents an include node.
*
- * @package twig
- * @author Fabien Potencier <fabien@symfony.com>
+ * @author Fabien Potencier <fabien@symfony.com>
*/
class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
{
@@ -39,21 +38,46 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
;
}
+ $this->addGetTemplate($compiler);
+
+ $compiler->raw('->display(');
+
+ $this->addTemplateArguments($compiler);
+
+ $compiler->raw(");\n");
+
+ if ($this->getAttribute('ignore_missing')) {
+ $compiler
+ ->outdent()
+ ->write("} catch (Twig_Error_Loader \$e) {\n")
+ ->indent()
+ ->write("// ignore missing template\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+ }
+
+ protected function addGetTemplate(Twig_Compiler $compiler)
+ {
if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) {
$compiler
->write("\$this->env->loadTemplate(")
->subcompile($this->getNode('expr'))
- ->raw(")->display(")
+ ->raw(")")
;
} else {
$compiler
->write("\$template = \$this->env->resolveTemplate(")
->subcompile($this->getNode('expr'))
->raw(");\n")
- ->write('$template->display(')
+ ->write('$template')
;
}
+ }
+ protected function addTemplateArguments(Twig_Compiler $compiler)
+ {
if (false === $this->getAttribute('only')) {
if (null === $this->getNode('variables')) {
$compiler->raw('$context');
@@ -71,18 +95,5 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
$compiler->subcompile($this->getNode('variables'));
}
}
-
- $compiler->raw(");\n");
-
- if ($this->getAttribute('ignore_missing')) {
- $compiler
- ->outdent()
- ->write("} catch (Twig_Error_Loader \$e) {\n")
- ->indent()
- ->write("// ignore missing template\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
}
}