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
Calling map with an array of objects where one of the objects doesn't have the given key, when strictVariables: true ends up in a weird interaction because of the call to _getFromScope.
Ruby simply returns nothing for those cases, liquidjs is instead rendering the error instead of throwing it.
it('should not throw or render an error', function () {
const posts = [{ category: 'foo' }, { name: 'bar' }]
return test('{{posts | map: "category"}}', { posts }, 'foo', { strictVariables: true })
})
This test results in:
● filters/array › map › should not throw or render an error
expect(received).toBe(expected) // Object.is equality
Expected: "foo"
Received: "InternalUndefinedVariableError: undefined variable: category"
Notice how the error is rendered into the output string, and not even thrown. Ruby doesn't throw though, with strict vars and strict filiters it simply doesn't return anything. Yo would get "foo" as output for the given test.
The text was updated successfully, but these errors were encountered:
I am not sure what features would break if I were to change that to be a regular object access and not use _getFromScope which seems to be causing the issue. Also I don't think I am smart enough to be able to follow all the generators chains. :(
ebobby
changed the title
map doesn't properly report errors.map renders an error when it shouldn't.
Aug 22, 2023
Calling
map
with an array of objects where one of the objects doesn't have the given key, whenstrictVariables: true
ends up in a weird interaction because of the call to_getFromScope
.Ruby simply returns nothing for those cases, liquidjs is instead rendering the error instead of throwing it.
This test results in:
Notice how the error is rendered into the output string, and not even thrown. Ruby doesn't throw though, with strict vars and strict filiters it simply doesn't return anything. Yo would get "foo" as output for the given test.
The text was updated successfully, but these errors were encountered: