Skip to content

Instantly share code, notes, and snippets.

@Invis1ble
Created August 19, 2014 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Invis1ble/0b7afb8fed8f7ca70f3c to your computer and use it in GitHub Desktop.
Save Invis1ble/0b7afb8fed8f7ca70f3c to your computer and use it in GitHub Desktop.
Twig compiler tweak: shows name of rendered template
protected function compileDisplayBody(Twig_Compiler $compiler)
{
$filename = $this->getAttribute('filename');
$compiler->write("echo '<!-- START " . $filename . (null !== $this->getNode('parent') ? " (has parent)" : '') . " -->';\n");
$compiler->subcompile($this->getNode('body'));
if (null !== $this->getNode('parent')) {
if ($this->getNode('parent') instanceof Twig_Node_Expression_Constant) {
$compiler->write("\$this->parent");
} else {
$compiler->write("\$this->getParent(\$context)");
}
$compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
}
$compiler->write("echo '<!-- END " . $filename . " -->';\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment