public function compile(\Twig_Compiler $compiler) { if ($this->getNode('default')) { $compiler->addDebugInfo($this)->write('echo $this->env->getExtension(\'defer\')->has(')->string($this->getAttribute('name'))->raw(") ? ")->write('$this->env->getExtension(\'defer\')->flush(')->string($this->getAttribute('name'))->raw(") : ")->subcompile($this->getNode('default'))->raw(";\n"); } else { $compiler->addDebugInfo($this)->write('echo $this->env->getExtension(\'defer\')->flush(')->string($this->getAttribute('name'))->raw(");\n"); } }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $attributes = $this->getAttribute('holder_attributes'); if ($attributes) { $compiler->addDebugInfo($this)->write('$this->env->getView()->placeholder(')->string($this->placeholder)->raw(')->set(')->subcompile($attributes)->raw(');'); } else { $compiler->addDebugInfo($this)->write('echo $this->env->getView()->placeholder(')->string($this->placeholder)->raw(');'); } }
public function compile(\Twig_Compiler $compiler) { if ($this->value instanceof \Twig_Node_Expression) { $compiler->addDebugInfo($this)->write('$this->env->getExtension(\'defer\')->defer(')->string($this->getAttribute('name'))->raw(', ')->subcompile($this->getNode('value'))->raw(");\n"); } else { // This is very ugly, but I don't know how else to handle \Twig_Node that compiles into this: echo "constant expression"; $compiler->write("\$deferred = function() use (\$context, \$blocks) {")->indent()->write("ob_start();\n")->write("try {\n")->indent()->subcompile($this->getNode('value'))->write("return ob_get_clean();")->outdent()->write("} catch (Exception \$e) {\n")->indent()->write("ob_end_clean();\n\n")->write("throw \$e;\n")->outdent()->write("} catch (Throwable \$e) {\n")->indent()->write("ob_end_clean();\n\n")->write("throw \$e;\n")->outdent()->write("}\n\n")->outdent()->write("};"); $compiler->addDebugInfo($this)->write('$this->env->getExtension(\'defer\')->defer(')->string($this->getAttribute('name'))->raw(', ')->write("\$deferred()")->raw(");\n"); } }
public function compile(\Twig_Compiler $compiler) { foreach ($this->getAttribute('above_dumps') as $aboveDump) { $compiler->subcompile($aboveDump); } $compiler->addDebugInfo($this)->write("ob_start();\n")->subcompile($this->getAttribute('below_dump')); $compiler->write("\$buffer = ob_get_clean();\n"); // echo $this->env->getExtension('stamp')->dumpStamp('svg'); $compiler->addDebugInfo($this)->write("echo \$this->env->getExtension('stamp')->dumpStamp(")->string($this->getAttribute('name'))->raw(");\n"); $compiler->write("echo \$buffer;\n"); }
public function compile(\Twig_Compiler $compiler) { // @codingStandardsIgnoreEnd $compiler->addDebugInfo($this); if ($this->assign) { $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = '); // @codingStandardsIgnoreStart } else { // @codingStandardsIgnoreEnd $compiler->raw('echo '); } $compiler->raw('$context[\'_view\']->cell('); $compiler->subcompile($this->getNode('name')); $data = $this->getNode('data'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($data); } $options = $this->getNode('options'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($options); } $compiler->raw(");\n"); }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler ->addDebugInfo($this) ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name'))) ; }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $template = $this->getNode('expr')->getAttribute('value'); $value = 'Elements' . DS . $template . '.tpl'; $this->getNode('expr')->setAttribute('value', $value); if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) { $compiler->write("\$this->env->loadTemplate(")->subcompile($this->getNode('expr'))->raw(")->display("); } else { $compiler->write("\$template = ")->subcompile($this->getNode('expr'))->raw(";\n")->write("if (!\$template")->raw(" instanceof Twig_Template) {\n")->indent()->write("\$template = \$this->env->loadTemplate(\$template);\n")->outdent()->write("}\n")->write('$template->display('); } if (false === $this->getAttribute('only')) { if (null === $this->getNode('variables')) { $compiler->raw('$context'); } else { $compiler->raw('array_merge($context, ')->subcompile($this->getNode('variables'))->raw(')'); } } else { if (null === $this->getNode('variables')) { $compiler->raw('array()'); } else { $compiler->subcompile($this->getNode('variables')); } } $compiler->raw(");\n"); }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $arguments = array(); foreach ($this->getNode('arguments') as $argument) { $arguments[] = '$'.$argument->getAttribute('name').' = null'; } $compiler ->addDebugInfo($this) ->write(sprintf("public function get%s(%s)\n", $this->getAttribute('name'), implode(', ', $arguments)), "{\n") ->indent() ->write("\$context = array_merge(\$this->env->getGlobals(), array(\n") ->indent() ; foreach ($this->getNode('arguments') as $argument) { $compiler ->write('') ->string($argument->getAttribute('name')) ->raw(' => $'.$argument->getAttribute('name')) ->raw(",\n") ; } $compiler ->outdent() ->write("));\n\n") ->write("ob_start();\n") ->subcompile($this->getNode('body')) ->raw("\n") ->write("return ob_get_clean();\n") ->outdent() ->write("}\n\n") ; }
public function compile(Twig_Compiler $compiler) { $name = $this->getAttribute('name'); $compiler->addDebugInfo($this); if ($this->getAttribute('is_defined_test')) { if ($this->isSpecial()) { $compiler->repr(true); } else { $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); } } elseif ($this->isSpecial()) { $compiler->raw($this->specialVars[$name]); } elseif ($this->getAttribute('always_defined')) { $compiler->raw('$context[')->string($name)->raw(']'); } else { if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) { $compiler->raw('(isset($context[')->string($name)->raw(']) ? $context[')->string($name)->raw('] : null)'); } else { // When Twig will require PHP 7.0, the Template::notFound() method // will be removed and the code inlined like this: // (function () { throw new Exception(...); })(); $compiler->raw('(isset($context[')->string($name)->raw(']) || array_key_exists(')->string($name)->raw(', $context) ? $context[')->string($name)->raw('] : $this->notFound(')->string($name)->raw(', ')->repr($this->lineno)->raw('))'); } } }
public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $type = $this->getAttribute('type'); $template = $type == \Wave\View\Tag\Register::TYPE_JS ? self::FORMAT_JS : self::FORMAT_CSS; $compiler->write('foreach($this->env->_wave_register["' . $type . '"] as $priority => $files):')->raw("\n\t")->write('foreach($files as $file => $extra):')->raw("\n\t")->write('$code = sprintf("' . $template . '", $file, $extra);')->raw("\n\t")->write('echo $code . "<!-- $priority -->\\n";')->raw("\n\t")->write('endforeach;')->raw("\n")->write('endforeach;')->raw("\n"); }
/** * {@inheritDoc} */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $this->compileAsset($compiler, $this->compressedAsset, $this->nameCompress); $this->compileDebug($compiler); $compiler->write('unset($context[')->repr($this->getAttribute('var_name'))->raw("]);\n"); }
public function compile(\Twig_Compiler $compiler) { $count = count($this->getNode('params')); if ($count == 1) { throw new \Twig_Error_Runtime('Content identifier is missing.'); } else { if ($count > 2) { throw new \Twig_Error_Runtime('Too many arguments.'); } } $compiler->addDebugInfo($this); for ($i = 0; $i < $count; $i++) { // argument is not an expression (such as, a \Twig_Node_Textbody) // we should trick with output buffering to get a valid argument to pass // to the functionToCall() function. if (!$this->getNode('params')->getNode($i) instanceof \Twig_Node_Expression) { $compiler->write('ob_start();')->raw(PHP_EOL); $compiler->subcompile($this->getNode('params')->getNode($i)); $compiler->write('$_content[] = ob_get_clean();')->raw(PHP_EOL); } else { $compiler->write('$_content[] = ')->subcompile($this->getNode('params')->getNode($i))->raw(';')->raw(PHP_EOL); } } $rawText = $this->retriever->render($this->getNode('params')->getNode(1)->getAttribute('value'), $this->getNode('params')->getNode(0)->getAttribute('data')); $compiler->raw('echo "' . str_replace('"', '\\"', $rawText) . '";')->raw(PHP_EOL); }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this); if ($this->getAttribute('ignore_missing')) { $compiler->write("try {\n")->indent(); } if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) { $compiler->write("\$this->env->loadTemplate(")->subcompile($this->getNode('expr'))->raw(")->display("); } else { $compiler->write("\$template = \$this->env->resolveTemplate(")->subcompile($this->getNode('expr'))->raw(");\n")->write('$template->display('); } if (false === $this->getAttribute('only')) { if (null === $this->getNode('variables')) { $compiler->raw('$context'); } else { $compiler->raw('array_merge($context, ')->subcompile($this->getNode('variables'))->raw(')'); } } else { if (null === $this->getNode('variables')) { $compiler->raw('array()'); } else { $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"); } }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this); list($msg, $vars) = $this->compileString($this->getNode('body')); if (null !== $this->getNode('plural')) { list($msg1, $vars1) = $this->compileString($this->getNode('plural')); $vars = array_merge($vars, $vars1); } $function = null === $this->getNode('plural') ? 'gettext' : 'ngettext'; if ($vars) { $compiler->write('echo strtr(' . $function . '(')->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')'); } $compiler->raw('), array('); foreach ($vars as $var) { if ('count' === $var->getAttribute('name')) { $compiler->string('%count%')->raw(' => abs(')->subcompile($this->getNode('count'))->raw('), '); } else { $compiler->string('%' . $var->getAttribute('name') . '%')->raw(' => ')->subcompile($var)->raw(', '); } } $compiler->raw("));\n"); } else { $compiler->write('echo ' . $function . '(')->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')'); } $compiler->raw(");\n"); } }
public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this)->write(sprintf('public function macro_%s(', $this->getAttribute('name'))); $count = count($this->getNode('arguments')); $pos = 0; foreach ($this->getNode('arguments') as $name => $default) { $compiler->raw('$__' . $name . '__ = ')->subcompile($default); if (++$pos < $count) { $compiler->raw(', '); } } if (PHP_VERSION_ID >= 50600) { if ($count) { $compiler->raw(', '); } $compiler->raw('...$__varargs__'); } $compiler->raw(")\n")->write("{\n")->indent(); $compiler->write("\$context = \$this->env->mergeGlobals(array(\n")->indent(); foreach ($this->getNode('arguments') as $name => $default) { $compiler->addIndentation()->string($name)->raw(' => $__' . $name . '__')->raw(",\n"); } $compiler->addIndentation()->string(self::VARARGS_NAME)->raw(' => '); if (PHP_VERSION_ID >= 50600) { $compiler->raw("\$__varargs__,\n"); } else { $compiler->raw('func_num_args() > ')->repr($count)->raw(' ? array_slice(func_get_args(), ')->repr($count)->raw(") : array(),\n"); } $compiler->outdent()->write("));\n\n")->write("\$blocks = array();\n\n")->write("ob_start();\n")->write("try {\n")->indent()->subcompile($this->getNode('body'))->raw("\n")->write("return ('' === \$tmp = ob_get_contents()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")->outdent()->write("} finally {\n")->indent()->write("ob_end_clean();\n")->outdent()->write("}\n")->outdent()->write("}\n\n"); }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); list($msg, $vars) = $this->compileString($this->getNode('body')); if (null !== $this->getNode('plural')) { list($msg1, $vars1) = $this->compileString($this->getNode('plural')); $vars = array_merge($vars, $vars1); } $function = null === $this->getNode('plural') ? '\\Skeleton\\I18n\\Translation::translate' : '\\Skeleton\\I18n\\Translation::translate_plural'; if ($vars) { $compiler->write('echo strtr(' . $function . '(')->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')'); } $compiler->raw(', $context[\'env\'][\'translation\']), array('); foreach ($vars as $var) { if ('count' === $var->getAttribute('name')) { $compiler->string('%count%')->raw(' => abs(')->subcompile($this->getNode('count'))->raw('), '); } else { $compiler->string('%' . $var->getAttribute('name') . '%')->raw(' => ')->subcompile($var)->raw(', '); } } $compiler->raw("));\n"); } else { $compiler->write('echo ' . $function . '(')->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->getNode('count'))->raw(')'); } $compiler->raw(", " . '$context[\'env\'][\'translation\']' . ");\n"); } }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this)->write("\$context['_parent'] = (array) \$context;\n")->write("\$context['_seq'] = twig_ensure_traversable(")->subcompile($this->getNode('seq'))->raw(");\n"); if (null !== $this->getNode('else')) { $compiler->write("\$context['_iterated'] = false;\n"); } if ($this->getAttribute('with_loop')) { $compiler->write("\$context['loop'] = array(\n")->write(" 'parent' => \$context['_parent'],\n")->write(" 'index0' => 0,\n")->write(" 'index' => 1,\n")->write(" 'first' => true,\n")->write(");\n"); if (!$this->getAttribute('ifexpr')) { $compiler->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n")->indent()->write("\$length = count(\$context['_seq']);\n")->write("\$context['loop']['revindex0'] = \$length - 1;\n")->write("\$context['loop']['revindex'] = \$length;\n")->write("\$context['loop']['length'] = \$length;\n")->write("\$context['loop']['last'] = 1 === \$length;\n")->outdent()->write("}\n"); } } $this->loop->setAttribute('else', null !== $this->getNode('else')); $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop')); $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr')); $compiler->write("foreach (\$context['_seq'] as ")->subcompile($this->getNode('key_target'))->raw(" => ")->subcompile($this->getNode('value_target'))->raw(") {\n")->indent()->subcompile($this->getNode('body'))->outdent()->write("}\n"); if (null !== $this->getNode('else')) { $compiler->write("if (!\$context['_iterated']) {\n")->indent()->subcompile($this->getNode('else'))->outdent()->write("}\n"); } $compiler->write("\$_parent = \$context['_parent'];\n"); // remove some "private" loop variables (needed for nested loops) $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\'' . $this->getNode('key_target')->getAttribute('name') . '\'], $context[\'' . $this->getNode('value_target')->getAttribute('name') . '\'], $context[\'_parent\'], $context[\'loop\']);' . "\n"); // keep the values set in the inner context for variables defined in the outer context $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n"); }
public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $compiler->write("try {\n")->indent(); $this->addGetTemplate($compiler); $compiler->outdent()->write("} catch (Twig_Error_Loader \$e) {\n")->indent()->write("throw new \\Exception(\$e);\n")->outdent()->write("}\n\n"); }
/** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this); list($msg, $vars) = $this->compileString($this->nodes['body']); if (null !== $this->nodes['plural']) { list($msg1, $vars1) = $this->compileString($this->nodes['plural']); $vars = array_merge($vars, $vars1); } $function = null === $this->nodes['plural'] ? '__' : '__n'; if ($vars) { $compiler->write('echo strtr(' . $function . '(')->subcompile($msg); if (null !== $this->nodes['plural']) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->nodes['count'])->raw(')'); } $compiler->raw(', true), array('); // modified: cakephp $return flag foreach ($vars as $var) { if ('count' === $var->getAttribute('name')) { $compiler->string('%count%')->raw(' => abs(')->subcompile($this->nodes['count'])->raw('), '); } else { $compiler->string('%' . $var->getAttribute('name') . '%')->raw(' => ')->subcompile($var)->raw(', '); } } $compiler->raw("));\n"); } else { $compiler->write('echo ' . $function . '(')->subcompile($msg); if (null !== $this->nodes['plural']) { $compiler->raw(', ')->subcompile($msg1)->raw(', abs(')->subcompile($this->nodes['count'])->raw(')'); } $compiler->raw(', true);'); // modified: cakephp $return flag } }
/** * Compiles the node to PHP. * * @param \Twig_Compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $compiler->write("\$location = ")->subcompile($this->getNode('expr'))->raw(";\n")->write("\$namespace = false;\n")->write("if (strpos(\$location, '@') === 0) {\n")->indent()->write("\$namespace = substr(\$location, 1, strpos(\$location, '/') - 1);\n")->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")->write("\$this->env->setNamespaceLookUpOrder(array(\$namespace, '__main__'));\n")->outdent()->write("}\n"); parent::compile($compiler); $compiler->write("if (\$namespace) {\n")->indent()->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")->outdent()->write("}\n"); }
/** * Compiles the node to PHP. * * @param \Twig_Compiler $compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $vars = $this->getNode('vars'); $defaults = new \Twig_Node_Expression_Array(array(), -1); if ($vars instanceof \Twig_Node_Expression_Array) { $defaults = $this->getNode('vars'); $vars = null; } list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars); $method = null === $this->getNode('count') ? 'trans' : 'transChoice'; $compiler->write('echo $this->env->getExtension(\'translator\')->getTranslator()->' . $method . '(')->subcompile($msg); $compiler->raw(', '); if (null !== $this->getNode('count')) { $compiler->subcompile($this->getNode('count'))->raw(', '); } if (null !== $vars) { $compiler->raw('array_merge(')->subcompile($defaults)->raw(', ')->subcompile($this->getNode('vars'))->raw(')'); } else { $compiler->subcompile($defaults); } $compiler->raw(', '); if (null === $this->getNode('domain')) { $compiler->repr('messages'); } else { $compiler->subcompile($this->getNode('domain')); } if (null !== $this->getNode('locale')) { $compiler->raw(', ')->subcompile($this->getNode('locale')); } $compiler->raw(");\n"); }
public function compile(Twig_Compiler $compiler) { $name = $this->getAttribute('name'); $compiler->addDebugInfo($this); if ($this->getAttribute('is_defined_test')) { if ($this->isSpecial()) { $compiler->repr(true); } else { $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); } } elseif ($this->isSpecial()) { $compiler->raw($this->specialVars[$name]); } elseif ($this->getAttribute('always_defined')) { $compiler->raw('$context[')->string($name)->raw(']'); } else { // remove the non-PHP 5.4 version when PHP 5.3 support is dropped // as the non-optimized version is just a workaround for slow ternary operator // when the context has a lot of variables if (PHP_VERSION_ID >= 50400) { // PHP 5.4 ternary operator performance was optimized $compiler->raw('(isset($context[')->string($name)->raw(']) ? $context[')->string($name)->raw('] : '); if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) { $compiler->raw('null)'); } else { $compiler->raw('$this->getContext($context, ')->string($name)->raw('))'); } } else { $compiler->raw('$this->getContext($context, ')->string($name); if ($this->getAttribute('ignore_strict_check')) { $compiler->raw(', true'); } $compiler->raw(')'); } } }
/** * Compiles the node to PHP. * * @param \Twig_Compiler $compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this)->write('echo $this->env->getExtension(\'form\')->setTheme(')->subcompile($this->getNode('form'))->raw(', array('); foreach ($this->getNode('resources') as $resource) { $compiler->subcompile($resource)->raw(', '); } $compiler->raw("));\n"); }
/** * Compiles the node to PHP. * * @param \Twig_Compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $config = $this->environment->get_phpbb_config(); $compiler->write("\$asset_file = ")->subcompile($this->getNode('expr'))->raw(";\n")->write("\$asset = new \\phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_path_helper());\n")->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")->indent()->write("\$asset_path = \$asset->get_path();")->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n")->write("if (!file_exists(\$local_file)) {\n")->indent()->write("\$local_file = \$this->getEnvironment()->findTemplate(\$asset_path);\n")->write("\$asset->set_path(\$local_file, true);\n")->outdent()->write("\$asset->add_assets_version('{$config['assets_version']}');\n")->write("\$asset_file = \$asset->get_url();\n")->write("}\n")->outdent()->write("}\n")->write("\$context['definition']->append('{$this->get_definition_name()}', '"); $this->append_asset($compiler); $compiler->raw("\n');\n"); }
/** * Compiles the node to PHP. * * @param Twig_Compiler $compiler A Twig_Compiler instance */ public function compile(Twig_Compiler $compiler) { if ($this->getAttribute('output')) { $compiler->addDebugInfo($this)->write("\$this->displayParentBlock(")->string($this->getAttribute('name'))->raw(", \$context, \$blocks);\n"); } else { $compiler->raw("\$this->renderParentBlock(")->string($this->getAttribute('name'))->raw(", \$context, \$blocks)"); } }
public function compile(\Twig_Compiler $compiler) { if ($this->type == 'header') { $body = $this->context->ui->header(); } else { $body = $this->context->ui->footer(); } $compiler->addDebugInfo($this)->write('echo ')->string($body)->raw(";\n"); }
/** * Compiles the node to PHP. * * @param \Twig_Compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $source = trim($this->getNode('body')->getAttribute('data')); $name = $this->getAttribute('name'); $geshi = new \GeSHi($source, $name); #$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); $parsedCode = sprintf('<div class="highlight highlight-%s">%s</div>', $name, $geshi->parse_code()); $compiler->addDebugInfo($this)->write('echo ')->string($parsedCode)->raw(";\n"); }
public function compile(\Twig_Compiler $compiler) { $arguments = $this->getAttribute('arguments'); $compiler->addDebugInfo($this)->write('$template_storage = new Bolt\\Storage($context[\'app\']);' . "\n")->write('$context[\'' . $this->getAttribute('name') . '\'] = ')->write('$template_storage->getContent(')->subcompile($this->getAttribute('contenttype'))->raw(", ")->subcompile($arguments); if (!is_null($this->getNode('wherearguments'))) { $compiler->raw(', $pager, ')->subcompile($this->getNode('wherearguments')); } $compiler->raw(" );\n"); }
public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); foreach ($this->_files as $file) { $compiler->write("// asset \"{$file}\"\n")->write('$context[')->repr($this->getAttribute('var_name'))->raw('] = ')->repr($this->getAssetUrl($file)); $compiler->raw(";\n")->subcompile($this->getNode('body')); $compiler->write('unset($context[')->repr($this->getAttribute('var_name'))->raw("]);\n"); } }
/** * Compiles a Exit_Node into PHP. * * @param \Twig_Compiler $compiler * * @return null */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); if ($status = $this->getNode('status')) { $compiler->write('throw new \\Craft\\HttpException(')->subcompile($status)->raw(");\n"); } else { $compiler->write("\\Craft\\craft()->end();\n"); } }