Closed roxblnfk closed 6 years ago
Maybe you miss this part about PHP-style vs. JS-style: https://phug-lang.com/#use-javascript-expressions
Example to use PHP-style with Pug-php:
<?php
use Pug\Pug;
include_once __DIR__ . '/vendor/autoload.php';
$pug = new Pug([
'expressionLanguage' => 'php',
]);
$pug->display('p=$user->name', [
'user' => (object) [
'name' => 'Bob',
],
]);
I run this code in the demo page and in the "PHP style" boxes of documentation pages.
Default is there expressionLanguage='auto'
. It is strange for the "PHP style" blocks
If i check expressionLanguage='php'
then it works. Sorry
auto
mode is JS-style, it's there for backward-compatibility with Pug-php 2.x. I recommend to always set explicitly the mode to js
or php
. Glad it works now. :)
Hello,
I encountered an issue with the following code (from official Phug documentation):
I expected to get:
But I actually get:
I know that it will work with code:
(without $)
Following code:
presumably causes a PHP error:
Thanks!