21 parent::__construct(array(
'body' => $body,
'arguments' => $arguments), array(
'name' => $name),
$lineno,
$tag);
33 ->write(sprintf(
"public function get%s(", $this->
getAttribute(
'name')))
38 foreach ($this->
getNode(
'arguments') as $name => $default) {
40 ->
raw(
'$_'.$name.
' = ')
41 ->subcompile($default)
44 if (++$pos < $count) {
56 $compiler->
write(
"\$context = \$this->env->getGlobals();\n\n");
59 ->
write(
"\$context = \$this->env->mergeGlobals(array(\n")
63 foreach ($this->
getNode(
'arguments') as $name => $default) {
79 ->
write(
"\$blocks = array();\n\n")
80 ->write(
"ob_start();\n")
83 ->subcompile($this->
getNode(
'body'))
85 ->write(
"} catch (Exception \$e) {\n")
87 ->write(
"ob_end_clean();\n\n")
88 ->write(
"throw \$e;\n")
91 ->write(
"return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
Compiles a node to PHP code.
outdent($step=1)
Outdents the generated code.
Represents a node in the AST.
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
getAttribute($name)
Gets an attribute.
addDebugInfo(Twig_NodeInterface $node)
Adds debugging information.
__construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag=null)
Represents a node in the AST.
raw($string)
Adds a raw string to the compiled code.
write()
Writes a string to the compiled code by adding indentation.
getNode($name)
Gets a node by name.