liquid: 'first' filter does not render liquid
Example: https://gist.github.com/alexcoco/473aad631353f8c55d82
It looks like it returns a string representation of the object instead of rendering it.
first
doesn’t appear to call to_liquid
whereas the for loop renders (and subsequently calls to_liquid
on) every object in the collection before entering the loop.
Presumably this is because Liquid does not render array elements until they’re being iterated over? But if they’re accessed without being iterated over then they’re not rendered when accessed.
I can print out all methods for the string: https://gist.github.com/alexcoco/663b1a9bfd05d5b70fb6
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 17 (17 by maintainers)
There are a couple ways you should be able to accomplish this. The first is by accessing the item with an array index:
And the second, while overkill for such a simple example, may be more useful based on what you’re trying to do: