mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Migrated asset and author helpers to es6 (#10611)
refs #9589 * update asset helper to use newer code standards * update authors helper to use newer code standards
This commit is contained in:
parent
0c77033d51
commit
960993b257
2 changed files with 28 additions and 24 deletions
|
@ -1,11 +1,11 @@
|
|||
// # Asset helper
|
||||
// Usage: `{{asset "css/screen.css"}}`, `{{asset "css/screen.css" ghost="true"}}`
|
||||
// Usage: `{{asset "css/screen.css"}}`
|
||||
//
|
||||
// Returns the path to the specified asset. The ghost flag outputs the asset path for the Ghost admin
|
||||
const proxy = require('./proxy'),
|
||||
get = require('lodash/get'),
|
||||
getAssetUrl = proxy.metaData.getAssetUrl,
|
||||
SafeString = proxy.SafeString;
|
||||
// Returns the path to the specified asset.
|
||||
const proxy = require('./proxy');
|
||||
const get = require('lodash/get');
|
||||
const {SafeString} = proxy;
|
||||
const {getAssetUrl} = proxy.metaData;
|
||||
|
||||
module.exports = function asset(path, options) {
|
||||
const hasMinFile = get(options, 'hash.hasMinFile');
|
||||
|
|
|
@ -6,27 +6,31 @@
|
|||
// By default, authors are separated by commas.
|
||||
//
|
||||
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
|
||||
const proxy = require('./proxy'),
|
||||
_ = require('lodash'),
|
||||
urlService = require('../services/url'),
|
||||
SafeString = proxy.SafeString,
|
||||
templates = proxy.templates,
|
||||
models = proxy.models;
|
||||
const proxy = require('./proxy');
|
||||
const _ = require('lodash');
|
||||
const urlService = require('../services/url');
|
||||
const {SafeString, templates, models} = proxy;
|
||||
|
||||
module.exports = function authors(options) {
|
||||
options = options || {};
|
||||
module.exports = function authors(options = {}) {
|
||||
options.hash = options.hash || {};
|
||||
|
||||
const autolink = !(_.isString(options.hash.autolink) && options.hash.autolink === 'false'),
|
||||
separator = _.isString(options.hash.separator) ? options.hash.separator : ', ',
|
||||
prefix = _.isString(options.hash.prefix) ? options.hash.prefix : '',
|
||||
suffix = _.isString(options.hash.suffix) ? options.hash.suffix : '',
|
||||
limit = options.hash.limit ? parseInt(options.hash.limit, 10) : undefined,
|
||||
visibilityArr = models.Base.Model.parseVisibilityString(options.hash.visibility);
|
||||
let {
|
||||
autolink,
|
||||
separator = ', ',
|
||||
prefix = '',
|
||||
suffix = '',
|
||||
limit,
|
||||
visibility,
|
||||
from = 1,
|
||||
to
|
||||
} = options.hash;
|
||||
let output = '';
|
||||
const visibilityArr = models.Base.Model.parseVisibilityString(visibility);
|
||||
|
||||
let output = '',
|
||||
from = options.hash.from ? parseInt(options.hash.from, 10) : 1,
|
||||
to = options.hash.to ? parseInt(options.hash.to, 10) : undefined;
|
||||
autolink = !(_.isString(autolink) && autolink === 'false');
|
||||
limit = limit ? parseInt(limit, 10) : limit;
|
||||
from = from ? parseInt(from, 10) : from;
|
||||
to = to ? parseInt(to, 10) : to;
|
||||
|
||||
function createAuthorsList(authors) {
|
||||
function processAuthor(author) {
|
||||
|
@ -36,7 +40,7 @@ module.exports = function authors(options) {
|
|||
}) : _.escape(author.name);
|
||||
}
|
||||
|
||||
return models.Base.Model.filterByVisibility(authors, visibilityArr, !!options.hash.visibility, processAuthor);
|
||||
return models.Base.Model.filterByVisibility(authors, visibilityArr, !!visibility, processAuthor);
|
||||
}
|
||||
|
||||
if (this.authors && this.authors.length) {
|
||||
|
|
Loading…
Reference in a new issue