Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Amd module return values #488

Merged
merged 2 commits into from

3 participants

@JamesMaroney

This is a rewrite of pull request #377

If building AMD module output and only one template/partial, return that compiled template as the module output. If building AMD module output and multiple templates/partials return the full hash of templates/partials.

@kpdecker kpdecker merged commit 4c35f89 into wycats:master
@blessenm

This seems to cause an issue when we specify a folder path as the input instead of filenames. I used the command like
handlebars templates/>templates.js -a -e html
And get an output file with return after every template in the folder.

@kpdecker
Collaborator

@blessenm Can you file a new bug for the issue you are seeing now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 8, 2013
  1. @JamesMaroney

    If building AMD modules, and only one template is being compiled,

    JamesMaroney authored
    return the compiled template from the AMD module
  2. @JamesMaroney

    If building AMD module and compiling multiple templates, return the full

    JamesMaroney authored
    templates (or partials) hash from the AMD module
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 bin/handlebars
View
9 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');
}
}
@@ -182,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('})();');
Something went wrong with that request. Please try again.