handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

StringHelpers.apply causes unexpected behavior

Open dontgitit opened this issue 3 years ago • 0 comments

If the context is falsy, apply will return the value of the first param. This seems to be unexpected?

For instance, {{abbreviate foo 5}} will render 5 if foo is undefined. I would expect to it render `` (the empty string) or perhaps even throw an exception, but certainly wouldn't expect 5.

Not sure if the abbreviate helper should maybe override apply instead of safeApply and treat context as an empty string if it's falsy? Either way, doesn't seem like desired behavior to render the first param if the context is falsy.

dontgitit avatar Feb 18 '22 01:02 dontgitit