Book Image

Web Development with Jade

By : Sean Lang
Book Image

Web Development with Jade

By: Sean Lang

Overview of this book

Table of Contents (16 chapters)

A warning about interpolation


Interpolation cannot be used in code blocks, including vanilla JS and the built-in variants. For example, consider the following code snippet:

Jade

HTML

- var there = "foo"
- title = "Hello #{there}"
p #{title}
<p>Hello #{there}</p>

If interpolation worked in code, it would print out Hello foo. The reason why interpolation can't be used in code blocks is because vanilla JS has no interpolation, and very little processing is done to the code before it is executed (even the built-in shorthands). So, allowing interpolation in these places would require extensive rewriting of the code blocks during compilation. However, once Template Strings are implemented in ES6 (the next version of JavaScript) this won't be an issue.