Now that you have Jade installed, you can use the jade
command to compile Jade files. For example, if we put some Jade in a file:
Then we can use the jade
command to render that file.
This will create file.html
, as shown:
By default, jade
compiles and renders the file, but if we only want it to compile into JS, we can use the --client
argument, as shown:
This results in some very ugly JS, mostly due to the debugging information. We can remove that debugging information with the --no-debug
argument.
The JS resulting from that could still be optimized a little bit more (and likely will be in future versions of the compiler), but because it's just machine-generated JS, it's not a huge issue. The important part is that this JS can be executed on the client side to render templates dynamically. This will be covered more in Chapter 4, Logic in Templates.
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.