Skip to content

Commit

Permalink
Migrated asset and author helpers to es6 (#10611)
Browse files Browse the repository at this point in the history
refs #9589

* update asset helper to use newer code standards

* update authors helper to use newer code standards
  • Loading branch information
vikaspotluri123 authored and rishabhgrg committed Mar 26, 2019
1 parent 0c77033 commit 960993b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
12 changes: 6 additions & 6 deletions core/server/helpers/asset.js
@@ -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');
Expand Down
44 changes: 24 additions & 20 deletions core/server/helpers/authors.js
Expand Up @@ -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;

module.exports = function authors(options) {
options = options || {};
options.hash = options.hash || {};
const proxy = require('./proxy');
const _ = require('lodash');
const urlService = require('../services/url');
const {SafeString, templates, models} = proxy;

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);
module.exports = function authors(options = {}) {
options.hash = options.hash || {};

let output = '',
from = options.hash.from ? parseInt(options.hash.from, 10) : 1,
to = options.hash.to ? parseInt(options.hash.to, 10) : undefined;
let {
autolink,
separator = ', ',
prefix = '',
suffix = '',
limit,
visibility,
from = 1,
to
} = options.hash;
let output = '';
const visibilityArr = models.Base.Model.parseVisibilityString(visibility);

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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 960993b

Please sign in to comment.