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.
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.
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.
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
Now, we can provide values for the
title
andbody
variables that are to be used by the template. This is done by specifying them in thedata
option that...