diff --git a/src/Pug/Engine/Options.php b/src/Pug/Engine/Options.php index c013a8e..fe3c2a2 100644 --- a/src/Pug/Engine/Options.php +++ b/src/Pug/Engine/Options.php @@ -65,7 +65,8 @@ protected function setUpFilterAutoload(&$options) if (class_exists($filter)) { $this->filters[$name] = method_exists($filter, 'pugInvoke') ? [new $filter(), 'pugInvoke'] - : (method_exists($filter, 'parse') + : ( + method_exists($filter, 'parse') ? [new $filter(), 'parse'] : $filter ); // @codeCoverageIgnore diff --git a/src/Pug/Engine/OptionsHandler.php b/src/Pug/Engine/OptionsHandler.php index 1df892d..0e9fa30 100644 --- a/src/Pug/Engine/OptionsHandler.php +++ b/src/Pug/Engine/OptionsHandler.php @@ -13,12 +13,12 @@ abstract class OptionsHandler extends PugJsEngine * @var array */ protected $optionsAliases = [ - 'cache' => 'cachedir', - 'prettyprint' => 'pretty', - 'allowMixedIndent' => 'allow_mixed_indent', - 'keepBaseName' => 'keep_base_name', - 'notFound' => 'not_found_template', - 'customKeywords' => 'keywords', + 'cache' => 'cachedir', + 'prettyprint' => 'pretty', + 'allowMixedIndent' => 'allow_mixed_indent', + 'keepBaseName' => 'keep_base_name', + 'notFound' => 'not_found_template', + 'customKeywords' => 'keywords', 'time_precision' => 'time_precision', 'line_height' => 'line_height', ]; diff --git a/src/Pug/Engine/PugJsEngine.php b/src/Pug/Engine/PugJsEngine.php index bb86c25..1d210ae 100644 --- a/src/Pug/Engine/PugJsEngine.php +++ b/src/Pug/Engine/PugJsEngine.php @@ -22,7 +22,8 @@ class PugJsEngine extends Keywords public function getNodeEngine() { if (!$this->nodeEngine) { - $this->nodeEngine = new NodejsPhpFallback($this->hasOption('node_path') + $this->nodeEngine = new NodejsPhpFallback( + $this->hasOption('node_path') ? $this->getDefaultOption('node_path') : 'node' ); @@ -50,7 +51,8 @@ protected function getHtml($file, array &$options) $directory = dirname($file); $renderFile = './render.' . time() . mt_rand(0, 999999999) . '.js'; chdir($directory); - file_put_contents($renderFile, + file_put_contents( + $renderFile, 'console.log(require(' . json_encode($realPath) . ')' . '(require(' . json_encode($options['obj']) . ')));' ); @@ -215,7 +217,9 @@ public function renderWithJs($input, $filename, $vars = null, $fallback = null) ]; $optionsFile = $workDirectory . '/options-' . mt_rand(0, 999999999) . '.js'; - file_put_contents($optionsFile, 'module.exports = require(' . + file_put_contents( + $optionsFile, + 'module.exports = require(' . json_encode(realpath(NodejsPhpFallback::getPrefixPath() . '/require.js')) . ').appendRequireMethod(' . (empty($vars) ? '{}' : json_encode($vars, JSON_UNESCAPED_SLASHES)) .