Check for unnecessary ``else`` clauses after an ``if``.
1 | 1 | var handlebars = require('handlebars'); |
|
2 | /** |
||
3 | * Handlebars block helper that checks if two values are equal. |
||
4 | * @param {mixed} a - First value to compare. |
||
5 | * @param {mixed} b - Second value to compare. |
||
6 | * @param {object} options - Handlebars object. |
||
7 | * @returns If the values are equal, content inside of the helper. If not, the content inside the `{{else}}` block. |
||
8 | */ |
||
9 | function ifEqual (a, b, options) { |
||
10 | 2 | if (a === b) return options.fn(this); |
|
11 | 1 | else return options.inverse(this); |
|
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
12 | }; |
||
13 | |||
14 | 1 | handlebars.registerHelper('ifEqual', ifEqual); |
|
15 | handlebars.registerHelper('ifequal', ifEqual); |
||
16 | module.exports = ifEqual; |