Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
eachIndexGroup(items, options) {
const data = handlebars.createFrame(options.data || {});
const indexGroups = {};
// doclet kinds that always get their own section
const sectionKinds = [
'class',
'interface',
'module',
'namespace'
];
function findNameKey({doclet, longname}) {
let previousMemberof;
const shortened = {
previous: null,
current: null,
next: null
};
Handlebars.registerHelper('list', function(context, options) {
var out = "<ul>",
data;
for (var i = 0; i < context.length; i++) {
if (options.data) {
data = Handlebars.createFrame(options.data || {});
data.index = i;
}
out += "<li>" + options.fn(context[i], {
data: data
}) + "</li>";
}
out += "</ul>";
return out;
});
data.forEach(function (D, I) {
var Data = handlebars.createFrame(options.data)
Data.refs = refs
if (I > 0) {
Data.page_prev = data[I - 1]
}
if (data[I + 1] !== undefined) {
Data.page_next = data[I + 1]
}
console.log('>> Writing the page:' + D.pagename)
fs.writeFileSync(options.data.configs.out_dir + D.pagename + '.html', options.fn(D, {data: Data}))
})
},
module.exports = function (n, block) {
var accum = ''
const data = require('handlebars').createFrame({})
for (var i = 0; i < n; ++i) {
data.index = i
accum += block.fn(this, { data: data })
}
return accum
}
Handlebars.registerHelper('people_join', (array, options) => {
const hash = options.hash;
const sep = hash.sep || ', ';
const use_and = hash.useAnd || true;
const minimal_number = hash.minNumber || 3;
let data = {};
if (options.data) {
data = Handlebars.createFrame(options.data);
}
if (array.length <= minimal_number) {
if (array.length === 1) {
return array.map((item, i) => { data.index = i; return options.fn(item, { data }); }).join(sep);
}
if (use_and) {
const display = array.slice(0, array.length - 1);
const separated = display.map((item, i) => { data.index = i; return options.fn(item, { data }); }).join(sep);
data.index = array.length - 1;
return `${separated} #POS#LANGl_and ${options.fn(array[array.length - 1], { data })}`;
}
return array.map((item, i) => { data.index = i; return options.fn(item, { data }); }).join(sep);
}
const display = array.slice(0, minimal_number);
module.exports = function(count, options) {
var str = '';
var data;
if (options.data) {
data = Handlebars.createFrame(options.data);
}
for (var i = 0; i < count; i++) {
if (data) {
data.index = i;
}
str += options.fn(this, { data: data });
}
return str;
}
Handlebars.registerHelper('eachWithSort', (array, key, direction, opts) => {
let data;
if (opts.data) {
data = Handlebars.createFrame(opts.data);
}
const sorted = array.sort((a, b) => {
a = a[key];
b = b[key];
if (direction === '-') {
return a < b ? 1 : a == b ? 0 : -1;
} else {
return a > b ? 1 : a == b ? 0 : -1;
}
});
let s = '';
set: function (name, value, options) {
var data = handlebars.createFrame(options.data)
data[name] = value
return options.fn(this, {data: data})
},
render: function (options) {
var data = handlebars.createFrame(options.data)
if (data.standard && data.standard.type === (this.type || options.hash.type)) {
Object.assign(data, data.standard)
} else {
Object.assign(data, helpers.data_for_render(this, options))
}
return options.fn(this, {data: data})
},
withOnly(options) {
const context = handlebars.createFrame(options.hash);
return options.fn(context);
}
};