diff --git a/composer.json b/composer.json index a90766ca..127ca66b 100644 --- a/composer.json +++ b/composer.json @@ -122,7 +122,7 @@ ], "require": { "php": ">=5.3.0", - "js-phpize/js-phpize": "^1.0" + "js-phpize/js-phpize": "^1.2" }, "require-dev": { "phpunit/phpunit": ">=4.0", diff --git a/src/Jade/Compiler.php b/src/Jade/Compiler.php index fbb5c101..cf56e72c 100644 --- a/src/Jade/Compiler.php +++ b/src/Jade/Compiler.php @@ -94,7 +94,10 @@ public function compile($node) $code = ltrim(implode('', $this->buffer)); if ($this->jsPhpize) { $dependencies = $this->jsPhpize->compileDependencies(); - $code = $this->createCode($dependencies) . $code; + if (!empty($dependencies)) { + $this->jsPhpize->flushDependencies(); + $code = $this->createCode($dependencies) . $code; + } } if ($this->phpSingleLine) { diff --git a/tests/features/issues.php b/tests/features/issues.php index b5356903..d2f9c166 100644 --- a/tests/features/issues.php +++ b/tests/features/issues.php @@ -150,9 +150,6 @@ public function testIssue92() $this->assertSame($expected, $actual); } - /** - * @group i72 - */ public function testIssue72() { $pug = new Pug(array( @@ -183,4 +180,25 @@ public function testIssue72() $this->assertSame($expected, $actual); } + + public function testIssue100() + { + $pug = new Pug(array( + 'expressionLanguage' => 'js', + )); + $actual = trim($pug->render('p Example #{item.name} #{helpers.format(\'money\', item.price)}', array( + 'item' => array( + 'name' => 'Foo', + 'price' => 12, + ), + 'helpers' => array( + 'format' => function ($type, $price) { + return $type . '-' . $price; + }, + ), + ))); + $expected = '
Example Foo money-12
'; + + $this->assertSame($expected, $actual); + } }