apostrophe
Advanced tools
Comparing version 0.4.122 to 0.4.123
@@ -473,2 +473,14 @@ | ||
return self.getAreaPlaintext(options); | ||
}, | ||
// Groups by the property named by 'key' on each of the values. | ||
// If the property referred to by the string 'key' is found to be | ||
// an array property of the first object, aposGroupByArray is called. | ||
// | ||
// Usage: {{ aposGroupBy(people, 'age') }} or {{ aposGroupBy(items, 'tags') }} | ||
aposGroupBy: function(items, key){ | ||
if(items.length && Array.isArray(items[0][key])) { | ||
return self._groupByArray(items, key); | ||
} | ||
return _.groupBy(items, key); | ||
} | ||
@@ -481,4 +493,18 @@ }; | ||
self.app.locals[name] = fn; | ||
}, | ||
// An extra bit of trickery to support arrays in self._locals.groupBy | ||
self._groupByArray =function(items, arrayName) { | ||
var results = {}; | ||
_.each(items, function(item) { | ||
_.each(item[arrayName] || [], function(inner) { | ||
if (!results[inner]) { | ||
results[inner] = []; | ||
} | ||
results[inner].push(item); | ||
}); | ||
}); | ||
return results; | ||
}; | ||
}; | ||
@@ -859,3 +859,3 @@ var _ = require('underscore'); | ||
if (slug !== originalSlug) { | ||
self.redirects.update( | ||
return self.redirects.update( | ||
{ from: originalSlug }, | ||
@@ -862,0 +862,0 @@ { from: originalSlug, to: slug }, |
{ | ||
"name": "apostrophe", | ||
"version": "0.4.122", | ||
"version": "0.4.123", | ||
"description": "Apostrophe is a user-friendly content management system. This core module of Apostrophe provides rich content editing and essential facilities to integrate Apostrophe into your Express project. Apostrophe also includes simple facilities for storing your rich content areas in MongoDB and fetching them back again. Additional functionality is available in modules like apostrophe-pages, apostrophe-snippets, apostrophe-blog, apostrophe-events, apostrophe-twitter and apostrophe-rss.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/apostrophe.js", |
3652924
33153