Skip to content

Commit

Permalink
add test and fix for PR meteor#5138
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 17, 2015
1 parent 77cc0c2 commit f10f6bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/spacebars-compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ _.extend(CodeGen.prototype, {

codeGenInclusionDataFunc: function (args) {
var self = this;
return 'function () { return ' + self.codeGenInclusionData(args) + '; }';
var dataCode = self.codeGenInclusionData(args);
if (dataCode) {
return 'function () { return ' + dataCode + '; }';
} else {
return null;
}
}

});
6 changes: 6 additions & 0 deletions packages/spacebars-tests/template_tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -1148,3 +1148,9 @@
<template name="spacebars_template_test_get_index">
<span>{{@index}}</span>
</template>

<template name="spacebars_template_test_each_in_multi_args">
{{#each item in helper list}}
<div>{{item}}</div>
{{/each}}
</template>
16 changes: 15 additions & 1 deletion packages/spacebars-tests/template_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ _.each(['textarea', 'text', 'password', 'submit', 'button',
},
type: type
});
};
}

var div = renderToDiv(tmpl);
document.body.appendChild(div);
Expand Down Expand Up @@ -3448,3 +3448,17 @@ Tinytest.add("spacebars-tests - template_tests - lexical scope doesn't leak", fu
var div = renderToDiv(tmpl);
}, /Unsupported directive/);
});

// PR #5138
Tinytest.add("spacebars-tests - template_tests - multiple arguments in each-in", function (test) {
var tmpl = Template.spacebars_template_test_each_in_multi_args;
tmpl.helpers({
list: ['a', 'b', 'c'],
helper: function (list) {
return list.reverse();
}
});

var div = renderToDiv(tmpl);
test.equal(canonicalizeHtml(div.innerHTML), "<div>c</div><div>b</div><div>a</div>");
});

0 comments on commit f10f6bf

Please sign in to comment.