Dynamic DIV IDs in Jade

Jade is an HTML templating language that works with Node.js and a bunch of other languages. It takes structured templates and converts them into HTML. Jade uses indentation to show what code should be within an HTML tag.

It is also possible to use variables to generate text, they call it Interpolation and it is a very handy feature. However, it is sometimes a little tricky to figure out how to use variables for attributes in tags.

For example if you want the variable local to serve a link in an Anchor tag, this would work:

a(href=local) Test Link

You can also combine variables and text:

a(href=’http://localhost:3000/page/’ + next_page ) Next

Doing the same for DIV IDs was a little trickier though. Since there is short had for assigning IDs, I thought I could just paste the variable in the shorthand. That didn’t work. However, using an approach similar to the Anchor tag does. Try this for using variables to assign the ID for a DIV:

div(id=permit_id)