teelou teelou - 5 months ago 36
Node.js Question

Jade template - does not process json in curly bracket after upgrading to pug?

Why jade does not process json properly anymore after upgrading to pug?

For instance:

a.btn.btn-link(href="/datasets/#{dataset.index}") Show


Result:

<a class="btn btn-link" href="/datasets/#{dataset.index}">Show</a>


It should be:

<a class="btn btn-link" href="/datasets/ISIUSXSXX">Show</a>


Any ideas why?

EDIT:

I think this is it:

a(href=`before${link}after`)


I seriously don't understand why would a developer chooses pug/jade - the the 'code' looks utterly ugly and unreadable! Just a rant!

Guy Guy
Answer

The syntax has changed to use ES6 template strings:

a.btn.btn-link(href="/datasets/#{dataset.index}")

becomes:

a.btn.btn-link(href=`/datasets/${dataset.index}`)

Reference issue

We removed support for interpolation in attributes since it was unnecessarily complex in implementation and tended to delay users learning that they can just use any JavaScript value in place of attributes