feat: support keyword arguments with no definition on custom filters#516
feat: support keyword arguments with no definition on custom filters#516juanazam wants to merge 1 commit intocobalt-org:masterfrom
Conversation
51c048c to
dd97d2f
Compare
dd97d2f to
e597967
Compare
|
This feels very hacked-in. Any idea how this is implemented with the ruby implementation? Its been a while since I've looked but my guess is they expose raw text for it to parse as they want rather than having any kind of higher level constructs to work with. |
|
Hi @epage Thanks for the feedback. Here is the implementation: https://github.com/Shopify/liquid/blob/0b9318222bcc09681e52fd5b8e70262274e673bf/lib/liquid/i18n.rb#L17 The translation fixture file contains: The call on the test In the case of rust-liquid, I couldn’t find another workaround on how to indicate that I want my custom filter to receive any arbitrary variables and not have to define them when defining the filter. This is necessary because liquid users can pass any variables to the filter and we cannot know them in advance. I will be glad to update this PR in any direction that feels better, but I’m not sure what’s the best way besides the one that I found. |
|
Hi @epage, did you have a chance to see this? thanks! |
|
Hey @epage any comments/advice on what can be done here? |
|
Hi @epage, any suggestions here on how to handle this? |
Implements the changes required to support what's described on #507.
In order to support arbitrary keyword arguments, this PR introduces a new type of parameter.
When defined, the
keyword_groupparameter is populated with all keyword parameters used to call the filter.It also disables the validation of only allowing known keyword parameters to be used on custom filters.
It also introduces a new variant for Expression (defined at runtime) to support this.
I can update this pr in any way maintainers feel it makes more sense.