Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test cases for custom functions in partials (#713)
These tests cases proves the partial indention changes that got
released in mustache v3.0.2 broke function output in partials
with indentation.
  • Loading branch information
wol-soft authored and phillipj committed Aug 26, 2019
1 parent 6c3608b commit c4e56ef
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion test/partial-test.js
Expand Up @@ -109,4 +109,34 @@ describe('Partials spec', function () {
var renderResult = Mustache.render(template, data, partials);
assert.equal(renderResult, expected);
});
});

it('Partial without indentation should inherit functions.', function () {
var template = '{{> partial }}';
var data = {
toUpperCase: function () {
return function (label) {
return label.toUpperCase();
};
}
};
var partials = {partial: 'aA-{{ #toUpperCase }}Input{{ /toUpperCase }}-Aa'};
var expected = 'aA-INPUT-Aa';
var renderResult = Mustache.render(template, data, partials);
assert.equal(renderResult, expected);
});

it('Partial with indentation should inherit functions.', function () {
var template = ' {{> partial }}';
var data = {
toUpperCase: function () {
return function (label) {
return label.toUpperCase();
};
}
};
var partials = {partial: 'aA-{{ #toUpperCase }}Input{{ /toUpperCase }}-Aa'};
var expected = ' aA-INPUT-Aa';
var renderResult = Mustache.render(template, data, partials);
assert.equal(renderResult, expected);
});
});

0 comments on commit c4e56ef

Please sign in to comment.