diff options
author | kpdecker <kpdecker@gmail.com> | 2014-11-27 09:11:03 -0600 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2014-11-27 09:11:03 -0600 |
commit | f990cf006422fbcbbae7d8a8a866831e58300ea4 (patch) | |
tree | 5511ccfde2f01f1018f6a73576ef393590cf5d5a /lib/handlebars/compiler/compiler.js | |
parent | 1124908d2a0d36493912eb2ce062545b1b5e5445 (diff) | |
download | handlebars.js-f990cf006422fbcbbae7d8a8a866831e58300ea4.zip handlebars.js-f990cf006422fbcbbae7d8a8a866831e58300ea4.tar.gz handlebars.js-f990cf006422fbcbbae7d8a8a866831e58300ea4.tar.bz2 |
Treat partial exec in a manner closer to helpers
This helps unify the code handling and will also be needed to support string/id tracking on partials.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index e73ce37..df5a10f 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -166,24 +166,15 @@ Compiler.prototype = { var partialName = partial.sexpr.path.original; this.usePartial = true; - if (partial.sexpr.hash) { - this.accept(partial.sexpr.hash); - } else { - this.opcode('pushLiteral', partial, 'undefined'); - } - var params = partial.sexpr.params; - if (params.length) { - if (params.length > 1) { - throw new Exception('Unsupported number of partial arguments: ' + params.length, partial); - } - - this.pushParam(params[0]); - } else { - this.opcode('getContext', partial, 0); - this.opcode('pushContext', partial); + if (params.length > 1) { + throw new Exception('Unsupported number of partial arguments: ' + params.length, partial); + } else if (!params.length) { + params.push({type: 'PathExpression', parts: [], depth: 0}); } + this.setupFullMustacheParams(partial.sexpr, undefined, undefined, true); + var indent = partial.indent || ''; if (this.options.preventIndent && indent) { this.opcode('appendContent', partial, indent); @@ -391,7 +382,7 @@ Compiler.prototype = { } }, - setupFullMustacheParams: function(sexpr, program, inverse) { + setupFullMustacheParams: function(sexpr, program, inverse, omitEmpty) { var params = sexpr.params; this.pushParams(params); @@ -401,7 +392,7 @@ Compiler.prototype = { if (sexpr.hash) { this.accept(sexpr.hash); } else { - this.opcode('emptyHash', sexpr); + this.opcode('emptyHash', sexpr, omitEmpty); } return params; |