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

Fix data merging & add pagination block param #5994

Merged
merged 1 commit into from
Oct 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions core/server/helpers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,24 @@ get = function get(context, options) {
apiOptions = parseOptions(this, apiOptions);

return apiMethod(apiOptions).then(function success(result) {
result = _.merge(self, result);
var blockParams;

// If no result is found, call the inverse or `{{else}}` function
if (_.isEmpty(result[context])) {
return options.inverse(self, {data: data});
}

// block params allows the theme developer to name the data using something like
// `{{#get "posts" as |result pagination|}}`
blockParams = [result[context]];
if (result.meta && result.meta.pagination) {
blockParams.push(result.meta.pagination);
}

// Call the main template function
return options.fn(result, {
data: data,
blockParams: [result[context]]
blockParams: blockParams
});
}).catch(function error(err) {
data.error = err.message;
Expand Down