Book Image

Grunt Cookbook

By : Jurie-Jan Botha
Book Image

Grunt Cookbook

By: Jurie-Jan Botha

Overview of this book

<p>A web application can quickly turn into a complex orchestration of many smaller components, each one requiring its own bit of maintenance. Grunt allows you to automate all the repetitive tasks required to get everything working together by using JavaScript, the most popular programming language.</p> <p>Grunt Cookbook offers a host of easy-to-follow recipes for automating repetitive tasks in your web application's development, management, and deployment processes. This book will introduce you to methods that can be used to automate basic processes and your favorite tools. By following the recipes, you will soon be comfortable using Grunt to perform a wide array of advanced tasks in a range of different scenarios.</p>
Table of Contents (17 chapters)
Grunt Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using data in a Jade template


Once we've got a Jade template, we can use it to render the same page structure with a variety of data. In this recipe, we'll make use of the contrib-jade (0.12.0) plugin in conjunction with the data option to send data that should be used in the rendering of the template.

Getting ready

In this example, we'll work with the basic project structure we created in the Rendering Jade templates recipe in this chapter. Be sure to refer to it if you are not yet familiar with its contents.

How to do it...

The following steps take us through providing data when rendering our template, and altering our index.jade template to make use of the provided data.

  1. First, we'll alter our index.jade template to make use of the variables provided by its context:

    doctype html
    html
      head
        title= title
      body
        h1= title
        p= body
    
  2. Now, we can provide values for the title and body variables that are to be used by the template. This is done by specifying them in the data option that...