Skip to content

Commit

Permalink
added test multiple subexpressions in a hash with context
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoZabcic authored and kpdecker committed Aug 23, 2014
1 parent cf343a1 commit f4b8c52
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/subexpressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand Down

0 comments on commit f4b8c52

Please sign in to comment.