Skip to content

Commit 587f0a1

Browse files
committed
Verbose event variable name
1 parent da80c6b commit 587f0a1

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/JsPhpize/JsPhpizePhug.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Phug\AbstractCompilerModule;
1010
use Phug\Compiler;
1111
use Phug\CompilerEvent;
12+
use Phug\Renderer;
1213
use Phug\Util\ModuleContainerInterface;
1314

1415
class JsPhpizePhug extends AbstractCompilerModule
@@ -17,6 +18,14 @@ public function __construct(ModuleContainerInterface $container)
1718
{
1819
parent::__construct($container);
1920

21+
if ($container instanceof Renderer) {
22+
$container->setOptionsRecursive([
23+
'compiler_modules' => [$this],
24+
]);
25+
26+
return;
27+
}
28+
2029
/* @var Compiler $compiler */
2130
$compiler = $container;
2231

@@ -86,19 +95,19 @@ public function compile(JsPhpize $jsPhpize, $code, $fileName)
8695
public function getEventListeners()
8796
{
8897
return [
89-
CompilerEvent::COMPILE => function (Compiler\Event\CompileEvent $e) {
90-
$e->getTarget()->setOption('jsphpize_engine', new JsPhpize($this->getOptions()));
98+
CompilerEvent::COMPILE => function (Compiler\Event\CompileEvent $event) {
99+
$event->getTarget()->setOption('jsphpize_engine', new JsPhpize($this->getOptions()));
91100
},
92101

93-
CompilerEvent::OUTPUT => function (Compiler\Event\OutputEvent $e) {
94-
$compiler = $e->getTarget();
102+
CompilerEvent::OUTPUT => function (Compiler\Event\OutputEvent $event) {
103+
$compiler = $event->getTarget();
95104

96105
/** @var JsPhpize $jsPhpize */
97106
$jsPhpize = $compiler->getOption('jsphpize_engine');
98107
$output = preg_replace(
99108
'/\{\s*\?><\?(?:php)?\s*\}/',
100109
'{}',
101-
$e->getOutput()
110+
$event->getOutput()
102111
);
103112
$output = preg_replace(
104113
'/\}\s*\?><\?(?:php)?\s*(' .
@@ -113,7 +122,7 @@ public function getEventListeners()
113122
$output = $compiler->getFormatter()->handleCode($dependencies) . $output;
114123
}
115124

116-
$e->setOutput($output);
125+
$event->setOutput($output);
117126

118127
$jsPhpize->flushDependencies();
119128
$compiler->unsetOption('jsphpize_engine');

0 commit comments

Comments
 (0)