Adding a new "where" filters
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
Hi,
The where filter is very useful, but I would suggest having a few improvements:
where_not
This filter would do the opposite of where filter:
{% assign blocks_to_render = section.blocks | where_not: 'type', 'divider' %}
Allow dot notation
With metafields and dynamic connection, it is increasingly common that merchant create a section with blocks, and bound the content with metafields.
For instance, let's imagine a "testimonials" section where the merchant would create 5 blocks. Some products may have 5, 4, 3, 2 or even no active blocks, depending on the product. This currently makes rendering very cumbersome. I would love having a dot notation. For instance:
{% assign rendered_blocks = section.blocks | where: 'settings.testimonial' %}
{% assign rendered_blocks = section.blocks | where: 'settings.product' %}
The idea here is to return actual block instances, but that would be filtered. This would allow to generate section code based on the actual content indicated by the merchant.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing where filter implementation and its tests. Review how filtering currently handles nested values, then define and verify the expected behavior for a where_not filter and dot notation such as settings.testimonial, including empty or missing values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100