Permalink
Browse files

Fixed code example

  • Loading branch information...
tj committed Sep 26, 2011
1 parent 27b7bac commit 5b54edc9798bdd35bf31e0f52841321a43f77697
Showing with 19 additions and 18 deletions.
  1. +11 −6 examples/code.jade
  2. +8 −12 examples/code.js
View
@@ -1,8 +1,13 @@
-- var title = "Things"
+
+// this expands to var title = "Things"
+title = "Things"
+
h1= title
+
ul#users
- - each user, name in users
- - if (user.isA == "ferret")
- li(class: 'user-' + name) #{name} is just a ferret
- - else
- li(class: 'user-' + name) #{name} #{user.email}
+ each user, name in users
+ // expands to if (user.isA == 'ferret')
+ if user.isA == 'ferret'
+ li(class='user-' + name) #{name} is just a ferret
+ else
+ li(class='user-' + name) #{name} #{user.email}
View
@@ -3,18 +3,14 @@
* Module dependencies.
*/
-var jade = require('./../lib/jade');
+var jade = require('./../')
+ , path = __dirname + '/code.jade'
+ , str = require('fs').readFileSync(path, 'utf8')
+ , fn = jade.compile(str, { filename: path, pretty: true });
-var options = {
- locals: {
- users: {
- tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' },
- tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' }
- }
- }
+var users = {
+ tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' },
+ tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' }
};
-jade.renderFile(__dirname + '/code.jade', options, function(err, html){
- if (err) throw err;
- console.log(html);
-});
+console.log(fn({ users: users }));

0 comments on commit 5b54edc

Please sign in to comment.