javascript:jade
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
javascript:jade [2014/03/18 03:36] – [Creating web pages] mithat | javascript:jade [2014/03/18 03:40] – [Creating web pages] mithat | ||
---|---|---|---|
Line 140: | Line 140: | ||
</ | </ | ||
- | ==== Creating web pages ==== | ||
- | |||
- | In this section, we will use Jade to build a simple but complete web page. It will serve as an introduction to some fundamental Jade language concepts. | ||
- | |||
- | <file jade myPage.jade> | ||
- | doctype html | ||
- | html | ||
- | head | ||
- | title A Simple Site | ||
- | body | ||
- | h1 Hello there! | ||
- | p Nice to meet you. | ||
- | </ | ||
- | |||
- | <file javascript buildMyPage.js> | ||
- | var jade = require(' | ||
- | var fs = require(' | ||
- | |||
- | options = { | ||
- | pretty: true | ||
- | }; | ||
- | |||
- | // Render an HTML page from a file written in Jade. | ||
- | var html = jade.renderFile(' | ||
- | if (err) { | ||
- | | ||
- | } | ||
- | return html; | ||
- | }); | ||
- | |||
- | // Write HTML to a file. | ||
- | fs.writeFile(' | ||
- | if (err) { | ||
- | throw(err); | ||
- | } | ||
- | }); | ||
- | </ | ||
- | |||
- | output:< | ||
- | $ cat myPage.html | ||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | </ | ||
- | </ | ||
- | |||
- | The basic idea is that Jade uses a shorthand HTML syntax where indentation is used to nest elements. | ||
- | |||
- | This should be enough to make you comfortable reading the [[http:// | ||