O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using mixins in Jade

Similar to partial templates in other template languages, Jade mixins are smaller template pieces that can accept parameters. Mixins are useful when generating common HTML chunks such as alert boxes, dialogs, and menus.

In this recipe we're going to compare Jade's mixins with the partial templates found in the other template languages by reimplementing the threaded conversation template. This is a recursive template that renders a threaded conversation tree.

Getting ready

We need to download jade.min.js in our recipe folder, available at https://github.com/visionmedia/jade.

How to do it...

Let's get started.

  1. Create index.html which will contain the conversation placeholder, the main conversation template, and the recursive partial ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required