Permalink
Browse files

Added examples

  • Loading branch information...
1 parent bc46ce5 commit 624e1684092f7e9d9f518374252b9c5b28451f16 @jheusala committed Aug 9, 2011
Showing with 59 additions and 0 deletions.
  1. +15 −0 examples/hello.js
  2. +15 −0 examples/partials.js
  3. +1 −0 examples/templates/hello.dust
  4. +19 −0 examples/templates/layout.dust
  5. +9 −0 examples/templates/partial.dust
View
@@ -0,0 +1,15 @@
+
+/* Foreach examples -- Automatic format */
+
+var dustfs = require('dustfs');
+
+dustfs.debug(true);
+
+dustfs.dirs('templates');
+
+dustfs.render('hello.dust', {'name':'Captain Jack'}, function(err, out) {
+ if(err) console.log('Error: '+err);
+ else console.log('Output:\n' + out);
+});
+
+/* EOF */
View
@@ -0,0 +1,15 @@
+
+/* Foreach examples -- Automatic format */
+
+var dustfs = require('dustfs');
+
+dustfs.debug(true);
+
+dustfs.dirs('templates');
+
+dustfs.render('partial.dust', {'name':'Captain Jack'}, function(err, out) {
+ if(err) console.log('Error: '+err);
+ else console.log('Output:\n' + out);
+});
+
+/* EOF */
@@ -0,0 +1 @@
+Hello {name}!
@@ -0,0 +1,19 @@
+<body>
+<div id="header">
+{+header}
+Header
+{/header}
+</div>
+
+<div id="content">
+{+content}
+Default content.
+{/content}
+</div>
+
+<div id="footer">
+{+footer}
+Default footer
+{/footer}
+</div>
+</body>
@@ -0,0 +1,9 @@
+{>"layout.dust"/}
+
+{<header}
+Hello, {name}!
+{/header}
+
+{<content}
+This is our own content.
+{/content}

0 comments on commit 624e168

Please sign in to comment.