You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our app we used the or-helper in a template condition with two parameters, the first a SafeString (created with htmlSafe) and the other a tracked local property.
{{#if (or @safeStringthis.trackedProperty)}}
... awesome application html
{{/if}}
The problem we faced is that since the @safeString is always an object (even if its an empty string) the or evaluates to true for it, but the ìf handles an empty safe string object properly and doesnt evaluate to true. This causes to never evaluate the second param, no matter if it changes to a "more truthy" value than the empty safe string. Is this something that should be changed or does it work as intended and should be addressed by the application? My problem with it is, that it handles htmlSafe in another way as the ìf-helper does.
At the moment we just simply add checks for the string before we create our SafeString, e.g.:
This way the or checks on a normal empty string, which evaluates to false and therefore checks also the second param. Of course there are several other approaches like changing the order of the params, putting the or logic in a local getter and so on, but thats not part of my original question
The text was updated successfully, but these errors were encountered:
markusm7
changed the title
Short-circuit Poblem With SafeString Using or (And Maybe Other Helper)
Short-circuit Problem With SafeString Using or (And Maybe Other Helper)
Apr 27, 2022
In our app we used the
or
-helper in a template condition with two parameters, the first aSafeString
(created withhtmlSafe
) and the other atracked
local property.The problem we faced is that since the
@safeString
is always an object (even if its an empty string) theor
evaluates to true for it, but theìf
handles an empty safe string object properly and doesnt evaluate to true. This causes to never evaluate the second param, no matter if it changes to a "more truthy" value than the empty safe string. Is this something that should be changed or does it work as intended and should be addressed by the application? My problem with it is, that it handles htmlSafe in another way as theìf
-helper does.At the moment we just simply add checks for the string before we create our
SafeString
, e.g.:This way the
or
checks on a normal empty string, which evaluates to false and therefore checks also the second param. Of course there are several other approaches like changing the order of the params, putting theor
logic in a local getter and so on, but thats not part of my original questionThe text was updated successfully, but these errors were encountered: