Jamgreen Jamgreen - 2 months ago 11
Jade Question

Element with id inside another element in jade/pug

I use

pug
/
jade
and I have this code

span <span id='numClients'>0</span> clients


So I want it to output

<span><span id="numClients">0</span> clients</span>


and it does work, but it's not pretty jade. How do you normally do this?

I could eventually use

span
span(id='numClients) 0
span clients


but it's not quite the same.

Answer

This is how you do it in jade/pug way.

span
    #[span#numClients 0] clients

This is called tag interpolation

Here's a documentation coming from jade/pug https://pugjs.org/language/interpolation.html

Hope it helps. Cheers!