Skip to content
Browse files

invoke jade parser

  • Loading branch information...
1 parent ec834d8 commit 276b221e5bddcdb51370932219add558d1b52e45 @dgreensp dgreensp committed May 2, 2012
Showing with 20 additions and 0 deletions.
  1. +20 −0 packages/jade/package.js
View
20 packages/jade/package.js
@@ -2,3 +2,23 @@ Package.describe({
summary: "Jade template engine"
});
+var jade = require('jade');
+var fs = require('fs');
+
+Package.register_extension(
+ "jade", function(bundle, source_path, serve_path, where) {
+ serve_path = serve_path + '.js';
+
+ var source = fs.readFileSync(source_path, 'utf8');
+
+ var parser = new jade.Parser(source, source_path);
+ var parsed = JSON.stringify(parser.parse());
+
+ bundle.add_resource({
+ type: 'js',
+ path: serve_path,
+ data: new Buffer('J='+parsed+';'),
+ where: where
+ });
+ }
+);

0 comments on commit 276b221

Please sign in to comment.
Something went wrong with that request. Please try again.