pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
391 stars 42 forks source link

Javascript Template Literal #176

Closed keyurshah closed 7 years ago

keyurshah commented 7 years ago

Hello,

I encountered an issue with the following code:

- var fruit = 'grapes'
p= `${fruit}`

I expected to get:

<p>grapes</p>

But I actually get:

<p></p>

I'm trying to set a template literal per ES6

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

I am instantiating pug as follows

        $pug = new Pug([
            'expressionLanguage' => 'js',
        ]);

Thanks!

kylekatarnls commented 7 years ago

Hi, the ES6 literal is not supported (and most of ES6 syntaxes), except with the 'pugjs' => true, but this option will totally disable PHP engine (class instances are flattened, PHP functions are not available) and will use the native node engine.

But, you can user simple concatenation:

- var fruit = 'grapes'
p= 'start' + fruit + 'end'

Or with 'expressionLanguage' => 'php', you can use PHP interpolation:

- $fruit = 'grapes'
p= "start ${fruit} end"
keyurshah commented 7 years ago

ok, thanks, i'll stick with the simle concatenation. appreciate the hard work on this great project!