Javascript – Jade/PUG JSON interpolation

javascriptjsonnode.jspugpugjs

First of all let me tell you that I'm not using Express but only Pug (formerly know as Jade).

I read a JSON object from an external file. Inside the object, one of the keys has a string value that looks like this:

This is #[strong cool]

Jade outputs it exactly as that but I'd wish to have the interpolation work for the read string. Any clues?

Thanks in advance!

Best Answer

You need to use This is #{strong cool}. Note the curly brackets.

And in case you miss it in the docs, Pug changed how interpolation works for attributes

It used to be

a(href="#{link}")
a(href='before#{link}after')

but now you should use

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