mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
ff73f1af92
no issue - update grunt-jscs dependency - fix deprecated `validateJSDoc` configuration - fix numerous linting errors, including: - use of future-reserved `public` and `private` variable names - use of `[]` instead of dot-notation (especially `express['static']` and `cacheRules['x']`) - extra spaces in `const { run } = Ember` style constructs One issue that did become apparent is that there are conflicting rules that prevent the use of object function shorthand such that both of these: ``` { myFunc() {} } { myFunc () {} } ``` are called out due to either the missing or the extra space before the `(`
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
// # Author Helper
|
|
// Usage: `{{author}}` OR `{{#author}}{{/author}}`
|
|
//
|
|
// Can be used as either an output or a block helper
|
|
//
|
|
// Output helper: `{{author}}`
|
|
// Returns the full name of the author of a given post, or a blank string
|
|
// if the author could not be determined.
|
|
//
|
|
// Block helper: `{{#author}}{{/author}}`
|
|
// This is the default handlebars behaviour of dropping into the author object scope
|
|
|
|
var hbs = require('express-hbs'),
|
|
_ = require('lodash'),
|
|
config = require('../config'),
|
|
utils = require('./utils'),
|
|
author;
|
|
|
|
author = function (context, options) {
|
|
if (_.isUndefined(options)) {
|
|
options = context;
|
|
}
|
|
|
|
if (options.fn) {
|
|
return hbs.handlebars.helpers.with.call(this, this.author, options);
|
|
}
|
|
|
|
var autolink = _.isString(options.hash.autolink) && options.hash.autolink === 'false' ? false : true,
|
|
output = '';
|
|
|
|
if (this.author && this.author.name) {
|
|
if (autolink) {
|
|
output = utils.linkTemplate({
|
|
url: config.urlFor('author', {author: this.author}),
|
|
text: _.escape(this.author.name)
|
|
});
|
|
} else {
|
|
output = _.escape(this.author.name);
|
|
}
|
|
}
|
|
|
|
return new hbs.handlebars.SafeString(output);
|
|
};
|
|
|
|
module.exports = author;
|