Concatenating a variable + string in Jade file

use #{} notation if you want to interpolate a variable in the contents of an element. you can just use the variable names straight up if you want to use them in attributes.

link(rel="stylesheet", href="https://stackoverflow.com/stylesheets/" + pref + '.css')

equivalent:

link(rel="stylesheet", href="https://stackoverflow.com/stylesheets/" + locals.pref + '.css')

when to use #{}:

a(href="https://stackoverflow.com/stylesheets/" + locals.pref + '.css') View the stylesheet at #{pref}

Leave a Comment