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)

Another warning about interpolation


Back in Chapter 3, Feeding Data into Templates, I mentioned that interpolation doesn't work in the arguments used to call a mixin. Now that we know how to write mixins, we need to be careful not to use interpolation when we're calling them. For example:

Jade

HTML

mixin hello(p)
  | #{p}

- title = "This is my Title"
p
  mixin hello('#{title}')
<p>#{title}</p>

If interpolation did work in mixin arguments, this would output This is my Title rather than #{title}.

This gotcha has existed since Jade's creation, and has been discussed on multiple occasions (refer to https://github.com/visionmedia/jade/issues/693) but probably won't be changed any time soon.