Skip to content

Commit

Permalink
Fix for issue #517.
Browse files Browse the repository at this point in the history
Now when compiiled with amd option and a single input argument, we are
checking to see whether the input is a file or folder.
  • Loading branch information
Blessan Mathew committed May 21, 2013
1 parent 5ba17c9 commit 69bcdf3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand All @@ -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 {
Expand Down

0 comments on commit 69bcdf3

Please sign in to comment.