2014-10-10 18:54:07 +04:00
|
|
|
// # Ghost Foot Helper
|
|
|
|
// Usage: `{{ghost_foot}}`
|
|
|
|
//
|
|
|
|
// Outputs scripts and other assets at the bottom of a Ghost theme
|
|
|
|
//
|
|
|
|
// We use the name ghost_foot to match the helper for consistency:
|
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
|
|
|
|
var hbs = require('express-hbs'),
|
|
|
|
_ = require('lodash'),
|
|
|
|
filters = require('../filters'),
|
2014-07-31 23:36:20 +04:00
|
|
|
api = require('../api'),
|
2014-10-10 18:54:07 +04:00
|
|
|
ghost_foot;
|
|
|
|
|
|
|
|
ghost_foot = function (options) {
|
|
|
|
/*jshint unused:false*/
|
2015-08-18 16:08:52 +03:00
|
|
|
var foot = [];
|
2014-10-10 18:54:07 +04:00
|
|
|
|
2014-07-31 23:36:20 +04:00
|
|
|
return api.settings.read({key: 'ghost_foot'}).then(function (response) {
|
|
|
|
foot.push(response.settings[0].value);
|
|
|
|
return filters.doFilter('ghost_foot', foot);
|
|
|
|
}).then(function (foot) {
|
|
|
|
var footString = _.reduce(foot, function (memo, item) { return memo + ' ' + item; }, '');
|
2014-10-10 18:54:07 +04:00
|
|
|
return new hbs.handlebars.SafeString(footString.trim());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ghost_foot;
|