Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for custom functions in partials #713

Merged
merged 3 commits into from Aug 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
});
});