diff --git a/content/plugins/fancyFirstChar.js b/content/plugins/fancyFirstChar.js
index 157fc71054..730111ff00 100644
--- a/content/plugins/fancyFirstChar.js
+++ b/content/plugins/fancyFirstChar.js
@@ -1,29 +1,36 @@
+var _ = require('underscore');
+
var fancyFirstChar;
+function fancify(originalContent) {
+ var newContent,
+ firstCharIndex = 0;
+
+ if (originalContent.substr(0, 1) === '<') {
+ firstCharIndex = originalContent.indexOf('>') + 1;
+ }
+
+ newContent = originalContent.substr(0, firstCharIndex);
+ newContent += '';
+ newContent += originalContent.substr(firstCharIndex, 1);
+ newContent += '';
+ newContent += originalContent.substr(firstCharIndex + 1, originalContent.length - firstCharIndex - 1);
+
+ return newContent;
+}
+
+
fancyFirstChar = {
init: function (ghost) {
ghost.registerFilter('prePostsRender', function (posts) {
- var post,
- originalContent,
- newContent,
- firstCharIndex = 0;
-
- for (post in posts) {
- if (posts.hasOwnProperty(post)) {
- originalContent = posts[post].content_html;
- if (originalContent.substr(0, 1) === '<') {
- firstCharIndex = originalContent.indexOf('>') + 1;
- }
-
- newContent = originalContent.substr(0, firstCharIndex);
- newContent += '';
- newContent += originalContent.substr(firstCharIndex, 1);
- newContent += '';
- newContent += originalContent.substr(firstCharIndex + 1, originalContent.length - firstCharIndex - 1);
-
- posts[post].content_html = newContent;
- }
+ if (_.isArray(posts)) {
+ _.each(posts, function (post) {
+ post.content_html = fancify(post.content_html);
+ });
+ } else if (posts.hasOwnProperty('content_html')) {
+ posts.content_html = fancify(posts.content_html);
}
+
return posts;
});
},
diff --git a/core/ghost.js b/core/ghost.js
index 9be4d0b467..59c999e1d7 100644
--- a/core/ghost.js
+++ b/core/ghost.js
@@ -234,7 +234,12 @@ Ghost.prototype.doFilter = function (name, args, callback) {
// Call each handler for this priority level
_.each(callbacks[priority], function (filterHandler) {
- args = filterHandler(args);
+ try {
+ args = filterHandler(args);
+ } catch (e) {
+ // If a filter causes an error, we log it so that it can be debugged, but do not throw the error
+ errors.logError(e);
+ }
});
});