Closed hax closed 7 years ago
Hi, unfortunatly, js expression is not yet implemented everywhere. For php/auto, only p= '$test'
seems wrong to me, it should render:
<p>$test</p>
All other codes seems right to me.
I'll try to fix the first one if I can.
Well, the problem here is if we treat strings as PHP syntax (just like pugjs drop '#{...}' in strings), there will be many compatibility problems for old php-jade users like our company.
Maybe the smooth path is introducing an separate option old-string-syntax
.
Hi, we will not be able to maintain backward compatibility. The next major version of Pug-php will match the pugjs 2 API and will drop all deprecated features. For example string interpolations in attributes will no longer be available in pugjs 2 so do we in pug-php 3 and the same way, we will filter strings to escape $
in ""
to get equivalent results to JS. But we might implement a ES2015 literals equivalent (strings with mini-quotes):
a(href=`/foo/${id}/bar`) #{id}
This syntax will be a job for the js-phpize project.
Hi, there is a new option now available to use the native pugjs engine (as an alternative if you still have blocking bugs with the PHP engine):
$pug = new Pug(array(
'pugjs' => true
));
echo $pug->render('
p= '$test'
p= "$test"
p= '$test' + test
p= "$test" + test
p= test
p #{test}
This is a pure wrapper solution with no PHP support in templates (all run with node.js).
This has changed in 3.0.0-alpha2
:
In default mode (expressionLanguage => "js"
witouht pugsjs
option) supposing test
variable is set to "foo"
:
p= "$test"
p= '#{$test}'
p= "#{$test}"
p #{$test}
p(
data-a='$test'
data-b="$test"
data-c='#{$test}'
data-d="#{$test}"
) test
Will render:
<p>$test</p>
<p>$test</p>
<p>#{$test}</p>
<p>#{$test}</p>
<p>foo</p>
<p data-a="$test" data-b="$test" data-c="#{$test}" data-d="#{$test}">test</p>
In php mode (expressionLanguage => "php"
), you will get:
<p>$test</p>
<p>foo</p>
<p>#{$test}</p>
<p>#foo</p>
<p data-a="$test" data-b="foo" data-c="#{$test}" data-d="#foo">test</p>
Please don't hesitate to test the new pug-php 3 and give us your feedback.
With data
['test' => 'testing']
and option expressionLangphp
orauto
, the result is:=
output uses PHP strings syntax and ignore the pug interpolations syntax#{expression}
. But attribute output does not use PHP strings syntax and process#{expression}
which is not very consistent.With expressionLang
js
the result is:=
output still uses PHP strings syntax which confused, and there are bug in process#{expression}
in attributes.