Closed stiebitzhofer closed 2 years ago
Returning a boolean instead of a string is not exactly what everyone would expect from this sort of function. So i suggest to do like the lodash.get method instead (which is wrapped by that Handlebars helper) and provide a default value as a 3rd argument of the helper.
get: function (object: Record<string, unknown>, path: string | string[], defaultValue = undefined) {
path = typeof path === 'string' ? path.split(',').map((val) => val.trim()) : path;
const result = get(object, path);
return result ? new SafeString(result) : defaultValue;
},
I am fine with that approach as well, it will solve my issue. Will test it locally.
Description
What keywords did you search in schema-tools issues before filing this one ?
get
Is this a BUG REPORT or FEATURE REQUEST ?
FEATURE REQUEST
What you expected to happen :
Return
false
if the result ofget
isundefined
. By this anif
statement in a handlebars template evaluates the result of the function properly.