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 87. Use a Jade Partial to Creat...

Hack 87. Use a Jade Partial to Create a Common Navigation Bar in Your Views

Now you can reuse content within your views through the use of partials.

To demonstrate this capability, let’s inject some shared content, such as a navigation bar, by creating a file named nav.jade and placing it into our views/partials directory:

ul.nav
 li.active
   a(href='/example1') Example1
 li
   a(href='/example2') Example2
 li
   a(href='/example3') Example3

We will also need to update our main app.js file, with our new routes:

app.get('/', routes.index);

app.get('/example1', routes.example1);

app.get('/example2', routes.example2);

app.get('/example3', routes.example3);

Now we need to build the three new example files. We’ll start with example1.jade:


  

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