From 69bcdf36c7c94781203d016fe2f151f47db125c6 Mon Sep 17 00:00:00 2001 From: Blessan Mathew Date: Tue, 21 May 2013 20:50:46 +0530 Subject: [PATCH] Fix for issue #517. Now when compiiled with amd option and a single input argument, we are checking to see whether the input is a file or folder. --- bin/handlebars | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/handlebars b/bin/handlebars index d605e74db..5b1ba89c9 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -168,10 +168,14 @@ function processTemplate(template, root) { if (argv.simple) { output.push(handlebars.precompile(data, options) + '\n'); } else if (argv.partial) { - if(argv.amd && argv._.length == 1){ output.push('return '); } + if(argv.amd && (argv._.length == 1 && !fs.statSync(argv._[0]).isDirectory())) { + output.push('return '); + } output.push('Handlebars.partials[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } else { - if(argv.amd && argv._.length == 1){ output.push('return '); } + if(argv.amd && (argv._.length == 1 && !fs.statSync(argv._[0]).isDirectory())) { + output.push('return '); + } output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } } @@ -184,7 +188,7 @@ argv._.forEach(function(template) { // Output the content if (!argv.simple) { if (argv.amd) { - if(argv._.length > 1){ + if(argv._.length > 1 || (argv._.length == 1 && fs.statSync(argv._[0]).isDirectory())) { if(argv.partial){ output.push('return Handlebars.partials;\n'); } else {