Rendering objects using Jade
Jade is a clean, terse template language. It uses significant whitespace to denote block and element hierarchy. It supports many advanced features, for example, mixins, which are subtemplates and blocks, which are template sections replaceable by inheritance.
In this recipe, we're going to render a simple greeting using Jade. Later on in this chapter, we're going to look at some of the more advanced features.
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.
Create
index.html
, it will contain a small form asking the user for his or her name, a placeholder to render the greeting, and the greeting template:<!DOCTYPE HTML> <html> <head> <title>Displaying an object with Jade </title> </head> <body> <form method="post"> <p>Name: <input id="name" type="text" name="name" value="John"></p> </form>...