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

Change filter front matter key to filterOut for v2.x #2522

Open
Zearin opened this issue Aug 8, 2022 · 9 comments · May be fixed by #3103
Open

Change filter front matter key to filterOut for v2.x #2522

Zearin opened this issue Aug 8, 2022 · 9 comments · May be fixed by #3103
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. enhancement

Comments

@Zearin
Copy link
Contributor

Zearin commented Aug 8, 2022

Is your feature request related to a problem? Please describe.
When writing a .filter( … ) function in JavaScript, I tend to think of it as “Filter FOR «truthy condition»”. In other words, I think in terms of what I want to include.

But the filter front matter key filters based on what you want to exclude.

Describe the solution you'd like
For more human-friendliness, I recommend changing the name of this key to filterOut for the official v2.x release of Eleventy.

Describe alternatives you've considered
Optionally, you could allow Eleventy to continue support for filter with a deprecation warning.

(You could also keep the filter keyword, and flip the logic that Eleventy uses…but that is hostile to users that have become used to the current behavior.)

@mayankkamboj47
Copy link
Contributor

Maybe we could use ‘exclude’ instead of ‘filterOut’ if that’s not already taken

@zachleat zachleat added the breaking-change This will have to be included with a major version as it breaks backwards compatibility. label Aug 22, 2022
@Snapstromegon
Copy link
Member

I agree with @mayankkamboj47 to choose 'exclude' over 'filterOut'. Not only because it seems more semantic to me, but it also allows for the addition of an 'include' property which might filter what to include from the collection.

@Zearin
Copy link
Contributor Author

Zearin commented Jan 20, 2023

@zachleat Please don’t forget this before v2.0 leaves beta! 🙏

@zachleat zachleat added this to the Eleventy 3.0.0 milestone Nov 10, 2023
@uncenter
Copy link
Contributor

I'm all for adding include and exclude properties and deprecating filter.

@Snapstromegon
Copy link
Member

Especially @zachleat:
I'm willing to create a PR for this, but how would you expect it to work when both include and exclude are specified?

I personally see these options:

1. Disallow
Just throw/warn/whatever when both keys are specified

2. Exclude over Include
Exclude items even when they are included.

3. Include over Exclude
Include items even when they are excluded.

I'd personally tend to use option 1, but I'm completely open to suggestions.

@uncenter
Copy link
Contributor

Option 1 is the only one that makes sense to me, I'd go with that.

@Zearin
Copy link
Contributor Author

Zearin commented Jan 13, 2024

Maybe this can squeeze in before the final release of v3?

@zachleat
Copy link
Member

zachleat commented May 1, 2024

Ruthlessly punting this one to 4.0, sorry!

@Zearin
Copy link
Contributor Author

Zearin commented May 1, 2024

😭

J/k. I'm good. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants