mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge branch 'pr/866' into devel
This commit is contained in:
@@ -28,7 +28,10 @@ Handlebars.json_ast_to_func = function (ast) {
|
||||
// what is passed in via named arguments.
|
||||
Handlebars._default_helpers = {
|
||||
'with': function (data, options) {
|
||||
return options.fn(data);
|
||||
if (!data || (data instanceof Array && !data.length))
|
||||
return options.inverse(this);
|
||||
else
|
||||
return options.fn(data);
|
||||
},
|
||||
'each': function (data, options) {
|
||||
var parentData = this;
|
||||
|
||||
@@ -355,3 +355,11 @@
|
||||
<template name="test_template_issue801">
|
||||
{{#each values}}{{this}}{{/each}}
|
||||
</template>
|
||||
|
||||
<!-- Test for issue #770 - falsy value for with -->
|
||||
<template name="test_template_issue770">
|
||||
{{# with value1}}{{this}}{{else}}xxx{{/with}}
|
||||
{{# with value2}}{{this}}{{else}}xxx{{/with}}
|
||||
{{# with value1}}{{this}}{{/with}}
|
||||
{{# with value2}}{{this}}{{/with}}
|
||||
</template>
|
||||
|
||||
@@ -1092,3 +1092,10 @@ Tinytest.add('templating - each falsy Issue #801', function (test) {
|
||||
var frag = Meteor.render(Template.test_template_issue801);
|
||||
test.equal(canonicalizeHtml(DomUtils.fragmentToHtml(frag)), "12null");
|
||||
});
|
||||
|
||||
Tinytest.add('templating - with falsy Issue #770', function (test) {
|
||||
Template.test_template_issue770.value1 = function () { return "abc"; };
|
||||
Template.test_template_issue770.value2 = function () { return false; };
|
||||
var frag = Meteor.render(Template.test_template_issue770);
|
||||
test.equal(canonicalizeHtml(DomUtils.fragmentToHtml(frag)), "abcxxxabc");
|
||||
});
|
||||
Reference in New Issue
Block a user