Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some needed tweaks I discovered while trying to use this in an Expres…

…s project
  • Loading branch information...
commit 1380f89daa23be9d0adf9332e6fd9ce4f14537d2 1 parent 580ab99
Joel Wietelmann jwietelmann authored
21 handlebars-precompiler.js
View
@@ -115,9 +115,6 @@ exports.watchDir = function(dir, outfile, extensions) {
var fs = require('fs')
, file = require('file');
- var viewDir = __dirname + '/test_views'
- , outfile = 'test_output.js'
-
var regex = /\.handlebars$/;
if(extensions) {
regex = new RegExp('\.' + extensions.join('$|\.') + '$');
@@ -127,19 +124,21 @@ exports.watchDir = function(dir, outfile, extensions) {
console.log('[' + event + '] detected in ' + (filename ? filename : '[filename not supported]'));
console.log('[compiling] ' + outfile);
exports.do({
- templates: [viewDir],
+ templates: [dir],
output: outfile,
fileRegex: regex,
- min: false
+ min: true
});
}
- file.walk(viewDir, function(_, dirPath, dirs, files) {
- for(var i = 0; i < files.length; i++) {
- var file = files[i];
- if(regex.test(file)) {
- fs.watch(file, compileOnChange);
- console.log('[watching] ' + file);
+ file.walk(dir, function(_, dirPath, dirs, files) {
+ if(files) {
+ for(var i = 0; i < files.length; i++) {
+ var file = files[i];
+ if(regex.test(file)) {
+ fs.watch(file, compileOnChange);
+ console.log('[watching] ' + file);
+ }
}
}
});
2  test.js
View
@@ -1,2 +1,2 @@
c = require('./handlebars-precompiler');
-c.watchDir(__dirname + '/test_views', 'test_output.js', ['handlebars', 'hbs']);
+c.watchDir(__dirname + '/test_views', __dirname + '/test_output.js', ['handlebars', 'hbs']);
2  test_views/comments/form.hbs
View
@@ -1 +1 @@
-<form>{{content}}</form>
+<form method="get">{{content}}</form>
2  test_views/users/listItem.handlebars
View
@@ -1 +1 @@
-<li>{{content}}</li>
+<li class="user">{{content}}</li>
Please sign in to comment.
Something went wrong with that request. Please try again.