Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.

Interpolation everywhere!


Now, how about actually putting the data into something? For this, we can use interpolation:

Jade

HTML

p Jade says #{some_text}!
<p>Jade says Hello World!</p>

You just wrap the variable that you want to use in between #{ and }, and everything in the curly braces is evaluated as code, rather than text. This can be used pretty much anywhere that text can. But what if we don't just want to insert a variable, but want to do something more?

Jade

HTML

p 2 times 3 is #{2 * 3}
<p>2 times 3 is 6</p>

Yep, interpolation can contain full expressions too—pretty much any code you would want to put directly inline. But wait, there's more!

It works in attributes:

Jade

HTML

- base_url = "http://slang.cx"
a(href="#{base_url}/about")
<a href="http://slang.cx/about"></a>

It even works in text blocks:

Jade

HTML

- i = ['proident', 'dreamcatcher', 'ennui', 'Tonx']

pre
   | #{i[0]} #{i[1]}
   | #{i[2]} #{i[3]}
<pre>proident dreamcatcher
ennui Tonx...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Web Development with Jade
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon