Skip to content

Commit 40d6882

Browse files
committed
Change helper signature
1 parent 43e4230 commit 40d6882

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

lib/generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ const registerHelpers = config => new Promise((resolve, reject) => {
206206
const file_path = path.resolve(config.templates, path.resolve(root, stats.name));
207207
// If it's a module constructor, inject dependencies to ensure consistent usage in remote templates in other projects or plain directories.
208208
const mod = require(file_path);
209-
if(typeof mod == "function") mod(_, Handlebars);
209+
if (typeof mod === 'function') mod(Handlebars, _);
210210
next();
211211
} catch (e) {
212212
reject(e);

templates/express/.helpers/all.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Module constructor provides dependency injection from the generator instead of relying on require's cache here to ensure
22
// the same instance of Handlebars gets the helpers installed and Lodash is definitiely available
33
// regardless of where remote templates reside: in another Node project or a plain directory, which may have different or no modules available.
4-
module.exports = (_, Handlebars) =>{
4+
module.exports = (Handlebars, _) =>{
55

66
/**
77
* Compares two values.

templates/markdown/.helpers/accepted-values.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('acceptedValues', items =>{
44
if(!items) return '<em>Any</em>';

templates/markdown/.helpers/build-path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('buildPath', (propName, path, key) => {
44
if (!path) return propName;

templates/markdown/.helpers/equal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('equal', (lvalue, rvalue, options) => {
44
if (arguments.length < 3)
55
throw new Error('Handlebars Helper equal needs 2 parameters');
66
if (lvalue!==rvalue) {
77
return options.inverse(this);
88
}
9-
9+
1010
return options.fn(this);
1111
});
1212

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('isRequired', (obj, key) => {
44
if (!obj || !obj.required) return false;
55
return !!(obj.required.includes(key));
66
});
7-
7+
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('stringify', json => {
44
try {
@@ -8,4 +8,4 @@ module.exports = (_, Handlebars) =>{
88
}
99
});
1010

11-
}
11+
}

templates/markdown/.helpers/tree.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
Handlebars.registerHelper('tree', path => {
44
if (!path) return '';
55
const filteredPaths = path.split('.').filter(Boolean);
66
if (!filteredPaths.length) return;
77
const dottedPath = filteredPaths.join('.');
8-
8+
99
return `${dottedPath}.`;
1010
});
11-
11+
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
/**
44
* Uppercases a string.
55
*/
66
Handlebars.registerHelper('uppercase', (str) => {
77
return str.toUpperCase();
88
});
9-
9+
1010
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
module.exports = (_, Handlebars) =>{
1+
module.exports = (Handlebars, _) =>{
22

33
/**
44
* Checks if a method is a valid HTTP method.
55
*/
66
Handlebars.registerHelper('validMethod', (method, options) => {
77
const authorized_methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'COPY', 'HEAD', 'OPTIONS', 'LINK', 'UNLIK', 'PURGE', 'LOCK', 'UNLOCK', 'PROPFIND'];
8-
8+
99
if (arguments.length < 3)
1010
throw new Error('Handlebars Helper validMethod needs 1 parameter');
1111
if (authorized_methods.indexOf(method.toUpperCase()) === -1) {
1212
return options.inverse(this);
1313
}
14-
14+
1515
return options.fn(this);
1616
});
17-
17+
1818
}

0 commit comments

Comments
 (0)