Skip to content

Commit c4e56ef

Browse files
wol-softphillipj
authored andcommitted
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.
1 parent 6c3608b commit c4e56ef

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

test/partial-test.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,34 @@ describe('Partials spec', function () {
109109
var renderResult = Mustache.render(template, data, partials);
110110
assert.equal(renderResult, expected);
111111
});
112-
});
112+
113+
it('Partial without indentation should inherit functions.', function () {
114+
var template = '{{> partial }}';
115+
var data = {
116+
toUpperCase: function () {
117+
return function (label) {
118+
return label.toUpperCase();
119+
};
120+
}
121+
};
122+
var partials = {partial: 'aA-{{ #toUpperCase }}Input{{ /toUpperCase }}-Aa'};
123+
var expected = 'aA-INPUT-Aa';
124+
var renderResult = Mustache.render(template, data, partials);
125+
assert.equal(renderResult, expected);
126+
});
127+
128+
it('Partial with indentation should inherit functions.', function () {
129+
var template = ' {{> partial }}';
130+
var data = {
131+
toUpperCase: function () {
132+
return function (label) {
133+
return label.toUpperCase();
134+
};
135+
}
136+
};
137+
var partials = {partial: 'aA-{{ #toUpperCase }}Input{{ /toUpperCase }}-Aa'};
138+
var expected = ' aA-INPUT-Aa';
139+
var renderResult = Mustache.render(template, data, partials);
140+
assert.equal(renderResult, expected);
141+
});
142+
});

0 commit comments

Comments
 (0)