summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-08-23 07:36:16 -0500
committerkpdecker <kpdecker@gmail.com>2014-08-23 07:36:16 -0500
commit67b3f40eb2041aa5c70609d666ecd12fb671142b (patch)
treeb90e591352256e63bc390a85d90b8a67f69ac21c
parentcf343a19495f92aba19111441f974588c835e735 (diff)
parent19ce9812965d1dcd15b93cf4e993f958d147179b (diff)
downloadhandlebars.js-67b3f40eb2041aa5c70609d666ecd12fb671142b.zip
handlebars.js-67b3f40eb2041aa5c70609d666ecd12fb671142b.tar.gz
handlebars.js-67b3f40eb2041aa5c70609d666ecd12fb671142b.tar.bz2
Merge branch 'evensoul-master'
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js7
-rw-r--r--spec/subexpressions.js24
2 files changed, 24 insertions, 7 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index a6930f0..7a4d987 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -545,13 +545,6 @@ JavaScriptCompiler.prototype = {
var lookup = (isSimple ? helper.name + ' || ' : '') + nonHelper + ' || helperMissing';
this.push('((' + lookup + ').call(' + helper.callParams + '))');
-
- // Always flush subexpressions. This is both to prevent the compounding size issue that
- // occurs when the code has to be duplicated for inlining and also to prevent errors
- // due to the incorrect options object being passed due to the shared register.
- if (!isRoot) {
- this.flushInline();
- }
},
// [invokeKnownHelper]
diff --git a/spec/subexpressions.js b/spec/subexpressions.js
index 0ecdbb9..5c9fdfc 100644
--- a/spec/subexpressions.js
+++ b/spec/subexpressions.js
@@ -139,6 +139,30 @@ describe('subexpressions', function() {
shouldCompileTo(string, [{}, helpers], '<input aria-label="Name" placeholder="Example User" />');
});
+ it("multiple subexpressions in a hash with context", function() {
+ var string = '{{input aria-label=(t item.field) placeholder=(t item.placeholder)}}';
+
+ var context = {
+ item: {
+ field: "Name",
+ placeholder: "Example User"
+ }
+ };
+
+ var helpers = {
+ input: function(options) {
+ var hash = options.hash;
+ var ariaLabel = Handlebars.Utils.escapeExpression(hash['aria-label']);
+ var placeholder = Handlebars.Utils.escapeExpression(hash.placeholder);
+ return new Handlebars.SafeString('<input aria-label="' + ariaLabel + '" placeholder="' + placeholder + '" />');
+ },
+ t: function(defaultString) {
+ return new Handlebars.SafeString(defaultString);
+ }
+ }
+ shouldCompileTo(string, [context, helpers], '<input aria-label="Name" placeholder="Example User" />');
+ });
+
it("in string params mode,", function() {
var template = CompilerContext.compile('{{snog (blorg foo x=y) yeah a=b}}', {stringParams: true});