Skip to content

Commit

Permalink
Provide compiler reference to hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Jun 7, 2017
1 parent 7a24174 commit 986e2bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Phug/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ protected function walkOption($option, callable $handler)
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
{
$this->walkOption('pre_compile_node', function (callable $preCompile) use (&$node) {
$preCompile($node);
$preCompile($node, $this);
});
foreach ($this->nodeCompilers as $className => $compiler) {
if (is_a($node, $className)) {
Expand All @@ -361,7 +361,7 @@ public function compileNode(NodeInterface $node, ElementInterface $parent = null

if ($element instanceof ElementInterface && !($element instanceof Block)) {
$this->walkOption('post_compile_node', function (callable $postCompile) use (&$element) {
$postCompile($element);
$postCompile($element, $this);
});
}

Expand Down Expand Up @@ -422,7 +422,7 @@ public function compileBlocks()
public function compile($pugInput, $fileName = null)
{
$this->walkOption('pre_compile', function (callable $preCompile) use (&$pugInput) {
$pugInput = $preCompile($pugInput);
$pugInput = $preCompile($pugInput, $this);
});
$element = $this->compileIntoElement($pugInput, $fileName);
$layout = $this->getLayout();
Expand All @@ -436,7 +436,7 @@ public function compile($pugInput, $fileName = null)
$phtml = $this->formatter->format($element);
$phtml = $this->formatter->formatDependencies().$phtml;
$this->walkOption('post_compile', function (callable $preCompile) use (&$phtml) {
$phtml = $preCompile($phtml);
$phtml = $preCompile($phtml, $this);
});

return $phtml;
Expand Down

0 comments on commit 986e2bd

Please sign in to comment.