Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding a handlebars flag so we can compile from Jade to Handlebars #729

Closed
wants to merge 1 commit into from

3 participants

@willrjmarshall

I've added a --handlebars flag to the binary.

Would this be better as a generic --prefix flag?

Needing to compile from Jade to Handlebars seems like a very likely situation, but the --prefix flag could hypothetically support any extension target.

@tj
Owner
tj commented

seems very unlikely to me personally, but yeah I would much rather a prefix thing, or just jade < in > out.hbs

@willrjmarshall

Hah, I'm currently having to compile Jade ---> Handlebars on two projects, which is why I bring this up.

I've also got a fix kicking around for a bug in the --watch behavior I found (it doesn't work when applied to directories).

With the two you could do something like:

jade --watch --prefix='hbs' app/templates/hbs & jade --watch app/assets
@ForbesLindesay

I can't see anywhere where we actually support compiling to handlebars. I guess it would be useful but it's unlikely to ever merit being in core. You could always supply your own compiler and do it that way without needing to modify core at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 2, 2012
  1. @willrjmarshall
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 bin/jade
View
5 bin/jade
@@ -31,6 +31,7 @@ program
.option('-c, --client', 'compile function for client-side runtime.js')
.option('-D, --no-debug', 'compile without debugging (smaller functions)')
.option('-w, --watch', 'watch files for changes and automatically re-render')
+ .option('-h, --handlebars', 'output files as .hbs instead of .html')
program.on('--help', function(){
console.log(' Examples:');
@@ -86,6 +87,8 @@ options.watch = program.watch;
// left-over args are file paths
+options.handlebars = program.handlebars;
+
var files = program.args;
// compile files
@@ -142,7 +145,7 @@ function renderFile(path) {
if (err) throw err;
options.filename = path;
var fn = jade.compile(str, options);
- var extname = options.client ? '.js' : '.html';
+ var extname = options.client ? '.js' : options.handlebars ? '.hbs' : '.html';
path = path.replace(re, extname);
if (program.out) path = join(program.out, basename(path));
var dir = resolve(dirname(path));
Something went wrong with that request. Please try again.