We have some components that are used to build pages, like normal, and some where we hydrate them with other data, so we are passing in arrays instead of entries.
If something is essentially an element, we need to do a .all()
to not have deprecation warnings, but if you do that on an array, you get errors. I've read through A similar question with element queries vs arrays but since I'm not explicitly running a query on the page, this isn't quite applicable.
Both arrays and objects are iterable
so that can't distinguish it. Ideally I'd like to do something like this:
{% if props.cards is array %}
{% set cardArray = props.cards %}
{% else %}
{% set cardArray = props.cards.all() %}
{% endif %}
{% for card in cardArray %}
...
Obviously, I'd be fine swapping the if/else conditions for the right test case