Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter bug ugly hack #560

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

cathysarisky
Copy link
Contributor

ref #464

This is an ugly hack for failure of the parser to recognize custom variables when included in complex filter expression.

There's probably a great way to use the AST parser to do this. I don't know what it is.

Tests pass. Will also commit (coming shortly!) a set of tests that cover this use of custom variables.

@allouis
Copy link
Contributor

allouis commented Oct 28, 2024

Hey @cathysarisky it would be great if you could add a test which shows an example of the current code failing - just so we can understand the problem better - from your issue description I think it's when using the get helper with a dynamic filter property - is that right? Something like this? {{#get "posts" filter="blah:{{@custom.thing}}"}}

I think introducing regex parsing to an AST based checker is a step backwards and I'd like to see this shipped using the AST - I think it's doable!

@cathysarisky cathysarisky marked this pull request as draft October 28, 2024 11:15
@cathysarisky
Copy link
Contributor Author

Right, {{#get "posts" filter="blah:{{@custom.thing}}"}} is the problem case. Struggled a bit with getting a test that worked. Will pick this back up when I get a chance / am in the mood to bang my head on it a bit more.

Agreed, my approach is Wrong.

@vikaspotluri123
Copy link
Member

vikaspotluri123 commented Oct 28, 2024

I think we need to reframe the issue to #get.filter should be type-checked, since it's special and we interpolate static values as part of the helper. This would enable e.g. no-unknown-globals as well

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.

3 participants