Skip to content

Commit

Permalink
rest-store: fixed missing totalCount
Browse files Browse the repository at this point in the history
templated: cleanup
  • Loading branch information
dvv committed Jul 26, 2010
1 parent bf8ff38 commit a216100
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/jsgi/rest-store.js
Expand Up @@ -94,7 +94,7 @@ exports.RestStore = function(options){
if(range){
// we have to wait for promise for counts to be set (e.g., mongo)
responseValue = when(responseValue, function(responseValue){
return when(responseValue.totalCount, function(count){
return responseValue && when(responseValue.totalCount, function(count){
delete responseValue.totalCount;
var end = start + (responseValue.length || 0) - 1;
headers["content-range"] = "items " + start + '-' + end + '/' + (count || '*');
Expand Down
3 changes: 2 additions & 1 deletion lib/jsgi/templated.js
Expand Up @@ -47,8 +47,9 @@ exports.Templated = function(options, nextApp){
return response;
// vanilla HTML -> wrap it in template
var vars = ((typeof options.vars === 'function') ? options.vars(request) : options.vars) || {};
vars.content = media.forEachableToString(response.body);
vars.content = (response.body.forEach) ? media.forEachableToString(response.body) : response.body;
//dir('CONTENT', response.body, vars.content);
return exports.render(options.template || 'index.html', vars);
var b = exports.renderPartial(options.template || 'index.html', vars);
//dir('BODY', b);
response.body = b;
Expand Down

0 comments on commit a216100

Please sign in to comment.