From 85a21f2359da7ad9e844996fbf3c2df5eea88459 Mon Sep 17 00:00:00 2001 From: James Maroney Date: Mon, 8 Apr 2013 10:36:43 -0400 Subject: [PATCH 1/2] If building AMD modules, and only one template is being compiled, return the compiled template from the AMD module --- bin/handlebars | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/handlebars b/bin/handlebars index 61886dac..1e46a35f 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -168,8 +168,10 @@ 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 '); } output.push('Handlebars.partials[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } else { + if(argv.amd && argv._.length == 1){ output.push('return '); } output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n'); } } From ca576c27fc313b63d526da49a57a0a27e10d9e97 Mon Sep 17 00:00:00 2001 From: James Maroney Date: Mon, 8 Apr 2013 10:37:18 -0400 Subject: [PATCH 2/2] If building AMD module and compiling multiple templates, return the full templates (or partials) hash from the AMD module --- bin/handlebars | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/handlebars b/bin/handlebars index 1e46a35f..d605e74d 100755 --- a/bin/handlebars +++ b/bin/handlebars @@ -184,6 +184,13 @@ argv._.forEach(function(template) { // Output the content if (!argv.simple) { if (argv.amd) { + if(argv._.length > 1){ + if(argv.partial){ + output.push('return Handlebars.partials;\n'); + } else { + output.push('return templates;\n'); + } + } output.push('});'); } else if (!argv.commonjs) { output.push('})();');