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)

Chapter 6. Mixins

Mixins are small, encapsulated pieces of code that are reusable throughout the template. They allow you to reduce redundancy (repeating chunks of code) and can make code easier to understand by providing good names for your mixins (more about this in Chapter 8, Organizing Jade Projects). Because they are encapsulated, they have their own variable scope, meaning they can prevent naming collisions that would likely happen in large templates that only use Jade's global namespace.

They are very similar to functions in JS; in fact, they compile into slightly modified functions and corresponding function calls. This means that almost everything that you already know about functions in JS carries over to mixins in Jade.