Skip to content

feat: add standard Shopify Liquid filters#146

Open
michaelhvisser wants to merge 3 commits intoosteele:mainfrom
michaelhvisser:feat/add-shopify-standard-filters
Open

feat: add standard Shopify Liquid filters#146
michaelhvisser wants to merge 3 commits intoosteele:mainfrom
michaelhvisser:feat/add-shopify-standard-filters

Conversation

@michaelhvisser
Copy link
Copy Markdown

Summary

  • 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

Checklist

  • I have read the contribution guidelines.
  • make test passes.
  • make lint passes.
  • New and changed code is covered by tests.
  • Performance improvements include benchmarks. (N/A — feature addition)
  • Changes match the documented (not just the implemented) behavior of Shopify.

Test plan

  • All new filters have table-driven test cases covering standard usage and edge cases
  • where filter tested with truthy check (1-arg), equality check (2-arg), and nil property values
  • sum filter tested with string arrays, integer arrays, and object property summation
  • at_least/at_most tested with values above and below the threshold
  • pluralize tested with integers, floats, and string counts
  • handleize/handle tested with special characters, empty strings, and leading/trailing dashes
  • remove_last/replace_last tested with matches and no-match cases
  • Full test suite passes with -race flag

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +271 to +274
if toFloat64(a) < toFloat64(b) {
return b
}
return a
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant