barbells
Version:
[//]: # ( ns__file unit: standard, comp: README.md )
54 lines (53 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHandlebars = void 0;
const { placeholders } = require('magicalstrings').constants;
function createHandlebars() {
const Handlebars = require('handlebars');
require('handlebars-helpers')({
handlebars: Handlebars,
});
Handlebars.registerHelper('openCurly', function () {
return '{';
});
Handlebars.registerHelper('closeCurly', function () {
return '}';
});
// this is maintained for backward compatibility
Handlebars.registerHelper('curly', function (object, open) {
return open ? '{' : '}';
});
Handlebars.registerHelper('safe', function (text) {
return new Handlebars.SafeString(text);
});
Handlebars.registerHelper('start', function (locationName) {
return new Handlebars.SafeString(placeholders.OPEN_COMMENT +
` ns__start_section ${locationName} ` +
placeholders.CLOSE_COMMENT);
});
Handlebars.registerHelper('end', function (locationName) {
return new Handlebars.SafeString(placeholders.OPEN_COMMENT +
` ns__end_section ${locationName} ` +
placeholders.CLOSE_COMMENT);
});
Handlebars.registerHelper('custom', function (locationName) {
return new Handlebars.SafeString(placeholders.OPEN_COMMENT +
` ns__custom_start ${locationName} ` +
placeholders.CLOSE_COMMENT + '\n' +
placeholders.OPEN_COMMENT +
` ns__custom_end ${locationName} ` +
placeholders.CLOSE_COMMENT);
});
Handlebars.registerHelper('customStart', function (locationName) {
return new Handlebars.SafeString(placeholders.OPEN_COMMENT +
` ns__custom_start ${locationName} ` +
placeholders.CLOSE_COMMENT);
});
Handlebars.registerHelper('customEnd', function (locationName) {
return new Handlebars.SafeString(placeholders.OPEN_COMMENT +
` ns__custom_end ${locationName} ` +
placeholders.CLOSE_COMMENT);
});
return Handlebars;
}
exports.createHandlebars = createHandlebars;