Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{{#each items}}
<li>{{agree_button}}</li>
{{/each}}
*/
})
var ast = Handlebars.parse(tpl)
// console.log(JSON.stringify(ast, null, 4));
var result = Mock4Tpl.gen(ast, null, {
'items|1-10': [{
'id|+1': 1,
name: '@FIRST @LAST',
emotion: '@SENTENCE'
}
]
}, Handlebars.helpers)
// console.log(JSON.stringify(result, null, 4))
// console.log(Handlebars.helpers)
test.ok(util.isArray(result.items))
test.ok(result.items.length >= 1 && result.items.length <= 10)
test.ok(!('agree_button' in result.items[0]))
test.ok('name' in result.items[0])
test.ok('emotion' in result.items[0])
test.done()
}
module.exports = function (config) {
// this is perhaps a bit janky. In dev mode, a `t` helper needs to be
// registered to render text in the static templates. Without the helper,
// all {{#t}} surrounded text is empty.
const handlebars = require('handlebars');
// This file is used by both the build system and the server.
// If part of the build system, `t` is already defined. Do not re-register
// or else the static templates are not translated.
if (! (handlebars.helpers && handlebars.helpers.t)) {
handlebars.registerHelper('t', function (msg) {
if (msg.fn) {
return this.format(this.gettext(msg.fn(this)), this);
}
return this.format(this.gettext(msg), this);
});
}
const abide = require('i18n-abide');
// Configure i18n-abide for loading gettext templates.
// This causes it to process the configuration settings, parse the
// message files for each language, etc.
//
handlebars.registerHelper('showCodeOrForm', function(data, options) {
var ret;
if (data.type === 'application/x-www-form-urlencoded') {
ret = handlebars.partials.parameters({
type: 'Form',
params: data.params,
});
} else {
ret = handlebars.helpers.showCode(
data.example,
{hash: {type: data.type}}
);
}
return new handlebars.SafeString(ret);
});
handlebars.registerHelper('showCode', function(data, options) {
function breadcrumb(model: Reflection, project: ProjectReflection, md: string[]) {
if (model && model.parent) {
breadcrumb(model.parent, project, md);
if (model.url) {
md.push(`[${model.name}](${Handlebars.helpers.relativeURL.call(this, model.url)})`);
} else {
md.push(model.url);
}
} else {
md.push(`[Globals](${Handlebars.helpers.relativeURL.call(this, project.url)})`);
}
return md.join(' › ');
}
$.each(arguments, function (i, arg) {
if(hb.helpers[arg])
{
helpers.push(hb.helpers[arg]);
}
else
{
value = arg;
$.each(helpers, function (j, helper) {
value = helper(value, arguments[i + 1]);
});
return false;
}
});
var handlebars = require('handlebars');
if (!handlebars.helpers.inlineLinks) {
throw new Error('inlineLinks helper not registered -- might not be the correct handlebars instance');
}
exports.linkPrefix = function() {
return '';
};
exports.packageVersion = function() {
return process.env.DOCS_PACKAGE_VERSION;
};
exports.typedef = function(options) {
options.hash.kind = 'typedef';
var result = handlebars.helpers._identifier(options);
return result ? options.fn(result) : 'ERROR, Cannot find typedef.';
};
export default function removeRootPath(obj, url, formater) {
obj = JSON.parse(JSON.stringify(obj).replace(new RegExp(JSON.parse(url).root, 'g'), ''))
obj = Handlebars.helpers[formater](obj)
return obj
}
tree.push(category);
const demo = allDemos.find((demo) => {
const demoCategorys = Array.isArray(demo.category) ? demo.category : [demo.category];
return arraysEqual([...demoCategorys, demo.title], tree);
});
if (!demo || !demo.path) {
if (tree.length === 1) {
const path = Handlebars.helpers.ms_path.call(
this, Handlebars.helpers.ms_finalpath.call(this, './index.html', opt), opt
);
const hash = (`${category}`).toLowerCase().replace(/ /g, '-');
return `<a href="${path}#${hash}">${category}</a>`;
}
return category;
}
const path = Handlebars.helpers.ms_path.call(
this, Handlebars.helpers.ms_finalpath.call(this, demo.path, opt), opt
);
return `<a href="${path}">${category}</a>`;
}).join(' > ');
});
Handlebars.registerHelper('timeOrCalculator', function(ezType) {
if(ezType=="time") {
return Handlebars.helpers.local("time");
} else {
return Handlebars.helpers.local("calculator");
}
});
tagClass : function(item) {
var cls = "label ";
var otherLabel = "label-" + Handlebars.helpers.formatTagLabelClass(item);
return cls + otherLabel;
}
});