2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00
Ghost/core/server/helpers/ghost_foot.js
Jason Williams de20f3af2a Match labels with element ids.
Refs #4578
- Match label "for" attributes with ids from the inputs they're
  labeling.
- Remove extra promise generation from ghost header and footer helpers.
2014-12-04 15:21:27 +00:00

36 lines
1.2 KiB
JavaScript

// # 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'),
config = require('../config'),
filters = require('../filters'),
api = require('../api'),
utils = require('./utils'),
ghost_foot;
ghost_foot = function (options) {
/*jshint unused:false*/
var jquery = utils.isProduction ? 'jquery.min.js' : 'jquery.js',
foot = [];
foot.push(utils.scriptTemplate({
source: config.paths.subdir + '/public/' + jquery,
version: config.assetHash
}));
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; }, '');
return new hbs.handlebars.SafeString(footString.trim());
});
};
module.exports = ghost_foot;