Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Pro HTML5 Application Hacks with Nod... > Hack 88. Use Jade Mixins to Populate...

Hack 88. Use Jade Mixins to Populate Your Views with Data

Jade mixins are another tool in your toolkit that you can utilize in your views to reduce code bloat. You can use mixins to help iterate through data from a web service, from a database, or in memory.

Let’s say we have a complex object being stored in memory or being persisted in a database. We would like to print out a few lists to display the data stored in this object.

To do this, we will use mixins. The power behind this feature is that we can now pass objects to our views, iterate through the data, and dynamically display its properties onto the screen. With mixins, we can pass parts of data as objects, nest mixins within mixins, and keep our code tidy, concise, and DRY.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint