Jamgreen Jamgreen - 10 months ago 58
Jade Question

Element with id inside another element in jade/pug

I use

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(id='numClients) 0
span clients

but it's not quite the same.

Answer Source

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

    #[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!