Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Web Development with Jade

You're reading from   Web Development with Jade Knowing Jade makes life simpler and more productive for web developers, and this book will teach you the language concisely and thoroughly using lots of practical examples and best practices for a solid grounding.

Arrow left icon
Product type Paperback
Published in Mar 2014
Publisher
ISBN-13 9781783286355
Length 80 pages
Edition Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Sean Lang Sean Lang
Author Profile Icon Sean Lang
Sean Lang
Arrow right icon
View More author details
Toc

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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime