Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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