javascript:jade
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
javascript:jade [2014/03/17 22:48] – mithat | javascript:jade [2014/03/18 03:41] (current) – removed mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Jade ====== | ||
- | |||
- | [[http:// | ||
- | |||
- | ===== Getting started ===== | ||
- | |||
- | ==== Installing Jade ==== | ||
- | To use Jade, you must first have Node.js installed on your system. On Windows and MacOS, you can use an [[http:// | ||
- | |||
- | Once you have Node.js installed, you have the choice of installing it so it available system-wide or only for a particular project. To make it available system-wide, | ||
- | |||
- | Until I get a good grasp of using Jade, I want to install it on a per-project basis. To do this, open a terminal in your project directory (or navigate to the directory) and enter < | ||
- | |||
- | When this is done you should see a '' | ||
- | |||
- | ==== Creating an HTML fragment ==== | ||
- | |||
- | The first thing we are going to do is use Jade to produce an HTML fragment. This is done with the '' | ||
- | <code javascript> | ||
- | var jade = require(' | ||
- | |||
- | // Render an HTML fragment from a string literal | ||
- | // written in Jade. | ||
- | var htmlFrag = jade.render(' | ||
- | |||
- | console.log(htmlFrag); | ||
- | </ | ||
- | |||
- | You can also create function that when called will return the fragment with the '' | ||
- | <code javascript> | ||
- | var jade = require(' | ||
- | |||
- | // Compile a function that produces an HTML fragment | ||
- | // from a string literal written in Jade. | ||
- | var frag = jade.compile(' | ||
- | |||
- | // Render stuff. | ||
- | var htmlFrag = frag(); | ||
- | |||
- | console.log(htmlFrag); | ||
- | </ | ||