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)) {
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);
}
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);
}
function createTagList(tags) {
function processTag(tag) {
return autolink ? templates.link({
url: urlService.getUrlByResourceId(tag.id, {withSubdirectory: true}),
text: _.escape(tag.name)
}) : _.escape(tag.name);
}
return ghostHelperUtils.visibility.filter(tags, options.hash.visibility, processTag);
}
function getKeywords(data) {
if (data.post && data.post.tags && data.post.tags.length > 0) {
return ghostHelperUtils.visibility.filter(data.post.tags, ['public'], function processItem(item) {
return item.name;
});
}
return null;
}