handlebars.js - How to check for empty-string, null or white-spaces in handlebar? - Stack Overflow

PHOTO EMBED

Fri Apr 29 2022 00:04:53 GMT+0000 (Coordinated Universal Time)

Saved by @Wchoi189

Handlebars.registerHelper('ifEmptyOrWhitespace', function (value, options) {
    if (!value) { return options.fn(this); }
    return value.replace(/\s*/g, '').length === 0
        ? options.fn(this)
        : options.inverse(this);
});
content_copyCOPY

https://stackoverflow.com/questions/39766555/how-to-check-for-empty-string-null-or-white-spaces-in-handlebar