1
0
mirror of https://github.com/actions/setup-python.git synced 2026-04-16 19:15:39 +02:00
Files
actions-setup-python/node_modules/handlebars/lib/handlebars/helpers/if.js
T
Danny McCormick 39c08a0eaa Initial pass
2019-06-26 21:12:00 -04:00

21 lines
895 B
JavaScript

import {isEmpty, isFunction} from '../utils';
export default function(instance) {
instance.registerHelper('if', function(conditional, options) {
if (isFunction(conditional)) { conditional = conditional.call(this); }
// Default behavior is to render the positive path if the value is truthy and not empty.
// The `includeZero` option may be set to treat the condtional as purely not empty based on the
// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
if ((!options.hash.includeZero && !conditional) || isEmpty(conditional)) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
instance.registerHelper('unless', function(conditional, options) {
return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
});
}