feat: add standard Shopify Liquid filters#146
feat: add standard Shopify Liquid filters#146michaelhvisser wants to merge 3 commits intoosteele:mainfrom
Conversation
Add 8 documented Shopify Liquid filters: where, sum, at_least, at_most, pluralize, handleize/handle, remove_last, and replace_last. Uses integer-aware arithmetic in sum and at_least/at_most to match existing filter conventions. Includes nil-safety guard in where filter's equality check to prevent reflect.TypeOf(nil) panic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7fc298b76
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…cion
Replace eqItems with values.Equal in whereFilter to fix two issues:
- Explicit nil target (e.g. where: "price", nil) panicked via
MustConvert(nil, interface{}) in the constant-arg function path
- Mixed numeric types (int vs float64) failed to match because
eqItems used strict Go == equality
values.Equal already handles nil comparison and numeric type coercion,
matching the behavior of Liquid's == operator.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6658bdaaae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
filters/standard_filters.go
Outdated
| if toFloat64(a) < toFloat64(b) { | ||
| return b | ||
| } | ||
| return a |
There was a problem hiding this comment.
Return numeric result in at_least/at_most
These filters compare operands numerically but then return the original operand (a/b) instead of a coerced number. For inputs like numeric strings, at_least/at_most can therefore return a string (for example, "6") even though they are documented and implemented elsewhere as number filters, which makes downstream type-sensitive behavior inconsistent; the same pattern appears in at_most immediately below and should be fixed there too.
Useful? React with 👍 / 👎.
Match the pattern used by plus/times/minus — return int64/float64 from toInt64/toFloat64 instead of the unconverted input values, ensuring consistent types when filters are chained. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
where,sum,at_least,at_most,pluralize,handleize/handle,remove_last, andreplace_lastsumandat_least/at_mostto match existing filter conventionswherefilter's equality check to preventreflect.TypeOf(nil)panicChecklist
make testpasses.make lintpasses.Test plan
wherefilter tested with truthy check (1-arg), equality check (2-arg), and nil property valuessumfilter tested with string arrays, integer arrays, and object property summationat_least/at_mosttested with values above and below the thresholdpluralizetested with integers, floats, and string countshandleize/handletested with special characters, empty strings, and leading/trailing dashesremove_last/replace_lasttested with matches and no-match cases-raceflag🤖 Generated with Claude Code