Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / handlebars / lib / handlebars / helpers / if.js
1 import {isEmpty, isFunction} from '../utils';
2
3 export default function(instance) {
4   instance.registerHelper('if', function(conditional, options) {
5     if (isFunction(conditional)) { conditional = conditional.call(this); }
6
7     // Default behavior is to render the positive path if the value is truthy and not empty.
8     // The `includeZero` option may be set to treat the condtional as purely not empty based on the
9     // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
10     if ((!options.hash.includeZero && !conditional) || isEmpty(conditional)) {
11       return options.inverse(this);
12     } else {
13       return options.fn(this);
14     }
15   });
16
17   instance.registerHelper('unless', function(conditional, options) {
18     return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
19   });
20 }