Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(i18n.t('warnings.helpers.foreach.iteratorNeeded'));
}
if (hbsUtils.isFunction(items)) {
items = items.call(this);
}
// Exclude items which should not be visible in the theme
items = ghostHelperUtils.visibility.filter(items, options.hash.visibility);
// Initial values set based on parameters sent through. If nothing sent, set to defaults
const {fn, inverse, hash, data, ids} = options;
let {columns, limit, from, to} = hash;
let length = _.size(items);
let output = '';
let frame;
let contextPath;
limit = parseInt(limit, 10) || length;
from = parseInt(from, 10) || 1;
to = parseInt(to, 10) || length;
// If a limit option was sent through (aka not equal to default (length))
// and from plus limit is less than the length, set to to the from + limit
if ((limit < length) && ((from + limit) <= length)) {
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(i18n.t('warnings.helpers.foreach.iteratorNeeded'));
}
if (hbsUtils.isFunction(items)) {
items = items.call(this);
}
// Exclude items which should not be visible in the theme
items = ghostHelperUtils.visibility.filter(items, options.hash.visibility);
// Initial values set based on parameters sent through. If nothing sent, set to defaults
const {fn, inverse, hash, data, ids} = options;
let {columns, limit, from, to} = hash;
let length = _.size(items);
let output = '';
let frame;
let contextPath;
limit = parseInt(limit, 10) || length;
from = parseInt(from, 10) || 1;
to = parseInt(to, 10) || length;
// If a limit option was sent through (aka not equal to default (length))
// and from plus limit is less than the length, set to to the from + limit
if ((limit < length) && ((from + limit) <= length)) {
'use strict';
// # Authors Helper
// Usage: `{{authors}}`, `{{authors separator=' - '}}`
//
// Returns a string of the authors on the post.
// By default, authors are separated by commas.
//
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
const proxy = require('./proxy');
const _ = require('lodash');
const urlService = require('../services/url');
const {SafeString, templates} = proxy;
const ghostHelperUtils = require('@tryghost/helpers').utils;
module.exports = function authors(options = {}) {
options.hash = options.hash || {};
let {
autolink,
separator = ', ',
prefix = '',
suffix = '',
limit,
visibility,
from = 1,
to
} = options.hash;
let output = '';
// # Foreach Helper
// Usage: `{{#foreach data}}{{/foreach}}`
//
// Block helper designed for looping through posts
const _ = require('lodash');
const {logging, i18n, hbs} = require('./proxy');
const {Utils: hbsUtils, handlebars: {createFrame}} = hbs;
const ghostHelperUtils = require('@tryghost/helpers').utils;
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(i18n.t('warnings.helpers.foreach.iteratorNeeded'));
}
if (hbsUtils.isFunction(items)) {
items = items.call(this);
}
// Exclude items which should not be visible in the theme
items = ghostHelperUtils.visibility.filter(items, options.hash.visibility);
// Initial values set based on parameters sent through. If nothing sent, set to defaults
const {fn, inverse, hash, data, ids} = options;
let {columns, limit, from, to} = hash;
// # Tags Helper
// Usage: `{{tags}}`, `{{tags separator=' - '}}`
//
// Returns a string of the tags on the post.
// By default, tags are separated by commas.
//
// Note that the standard {{#each tags}} implementation is unaffected by this helper
const proxy = require('./proxy');
const _ = require('lodash');
const ghostHelperUtils = require('@tryghost/helpers').utils;
const urlService = proxy.urlService;
const SafeString = proxy.SafeString;
const templates = proxy.templates;
module.exports = function tags(options) {
options = 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;
let output = '',
'use strict';
// # Authors Helper
// Usage: `{{authors}}`, `{{authors separator=' - '}}`
//
// Returns a string of the authors on the post.
// By default, authors are separated by commas.
//
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
const proxy = require('./proxy');
const _ = require('lodash');
const urlService = require('../services/url');
const {SafeString, templates} = proxy;
const ghostHelperUtils = require('@tryghost/helpers').utils;
module.exports = function authors(options = {}) {
options.hash = options.hash || {};
let {
autolink,
separator = ', ',
prefix = '',
suffix = '',
limit,
visibility,
from = 1,
to
} = options.hash;
let output = '';
// # Foreach Helper
// Usage: `{{#foreach data}}{{/foreach}}`
//
// Block helper designed for looping through posts
const _ = require('lodash');
const {logging, i18n, hbs} = require('./proxy');
const {Utils: hbsUtils, handlebars: {createFrame}} = hbs;
const ghostHelperUtils = require('@tryghost/helpers').utils;
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(i18n.t('warnings.helpers.foreach.iteratorNeeded'));
}
if (hbsUtils.isFunction(items)) {
items = items.call(this);
}
// Exclude items which should not be visible in the theme
items = ghostHelperUtils.visibility.filter(items, options.hash.visibility);
// Initial values set based on parameters sent through. If nothing sent, set to defaults
const {fn, inverse, hash, data, ids} = options;
let {columns, limit, from, to} = hash;
module.exports = function reading_time(options) {// eslint-disable-line camelcase
options = options || {};
options.hash = options.hash || {};
// only calculate reading time for posts
if (!schema.isPost(this)) {
return null;
}
let readingTime = calculateReadingTime(this, options.hash);
return new SafeString(readingTime);
};
module.exports = function reading_time(options) {// eslint-disable-line camelcase
options = options || {};
options.hash = options.hash || {};
// only calculate reading time for posts
if (!schema.isPost(this)) {
return null;
}
let readingTime = calculateReadingTime(this, options.hash);
return new SafeString(readingTime);
};
function createAuthorsList(authors) {
function processAuthor(author) {
return autolink ? templates.link({
url: urlService.getUrlByResourceId(author.id, {withSubdirectory: true}),
text: _.escape(author.name)
}) : _.escape(author.name);
}
return ghostHelperUtils.visibility.filter(authors, visibility, processAuthor);
}