Created
August 19, 2014 23:46
-
-
Save Invis1ble/0b7afb8fed8f7ca70f3c to your computer and use it in GitHub Desktop.
Twig compiler tweak: shows name of rendered template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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