Skip to content

feat: add named filter arguments and allow_false for default filter - #143

Merged
osteele merged 1 commit into
mainfrom
named-filter-args
Aug 11, 2026
Merged

feat: add named filter arguments and allow_false for default filter#143
osteele merged 1 commit into
mainfrom
named-filter-args

Conversation

@osteele

@osteele osteele commented Feb 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add support for keyword arguments in filter expressions (e.g., {{ val | default: "fallback", allow_false: true }})
  • Keyword arguments are parsed by the yacc grammar and collected into a map[string]any passed as a variadic trailing parameter to filter functions
  • The default filter now accepts allow_false: true to preserve false values instead of replacing them with the default

Closes #42, closes #75

Changes

  • expressions/builders.go: Added filterArgs and keywordArg types
  • expressions/expressions.y: Extended filter_params grammar rule to accept KEYWORD expr pairs; changed union type from []valueFn to *filterArgs
  • expressions/y.go: Regenerated from expressions.y
  • expressions/context.go: Updated Context interface signature for ApplyFilter
  • expressions/filters.go: Updated ApplyFilter to evaluate keyword args into a map[string]any and append as trailing argument
  • expressions/filters_test.go: Updated tests for new filterArgs type; added keyword args test
  • filters/standard_filters.go: Updated default filter to accept variadic kwargs and check for allow_false
  • filters/standard_filters_test.go: Added test cases for allow_false behavior

Test plan

  • All existing tests pass
  • New tests for allow_false: true with false, nil, empty string values
  • New test for keyword arg passthrough via ApplyFilter
  • Existing filter tests updated for new filterArgs type

@osteele
osteele force-pushed the named-filter-args branch 2 times, most recently from c285152 to 0e77c41 Compare August 11, 2026 22:25
@osteele
osteele force-pushed the named-filter-args branch from 0e77c41 to 553eac5 Compare August 11, 2026 22:29
@osteele
osteele merged commit 756fcdd into main Aug 11, 2026
12 checks passed
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.

Please support allow_false feature Add support for named filter arguments

1 participant