1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const inflection = require('inflection');
|
4 | const changeCase = require('change-case');
|
5 |
|
6 | inflection.undasherize = str => str.split(/[-_]/).map(w => w[0].toUpperCase() + w.slice(1).toLowerCase()).join('');
|
7 | const helpers = {
|
8 | capitalize(string) {
|
9 | return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
10 | },
|
11 | inflection,
|
12 | changeCase
|
13 | };
|
14 | const doCapitalization = (hsh, [key, value]) => {
|
15 | hsh[key] = value;
|
16 | if (localsToCapitalize.includes(key))
|
17 | hsh[helpers.capitalize(key)] = helpers.capitalize(value);
|
18 | return hsh;
|
19 | };
|
20 | const localsToCapitalize = ['name'];
|
21 | const localsDefaults = {
|
22 | name: 'unnamed'
|
23 | };
|
24 | const capitalizedLocals = (locals) => Object.entries(locals).reduce(doCapitalization, {});
|
25 | const context = (locals, config) => {
|
26 | const localsWithDefaults = Object.assign({}, localsDefaults, locals);
|
27 | const configHelpers = config && (typeof config.helpers === "function" ? config.helpers(locals, config) : config.helpers) || {};
|
28 | return Object.assign(localsWithDefaults, capitalizedLocals(localsWithDefaults), {
|
29 | h: Object.assign(Object.assign({}, helpers), configHelpers)
|
30 | });
|
31 | };
|
32 | module.exports = context;
|
33 |
|
\ | No newline at end of file |