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

Support aggregation for filter addition #3387

Closed
LeaVerou opened this issue Jul 28, 2024 · 2 comments
Closed

Support aggregation for filter addition #3387

LeaVerou opened this issue Jul 28, 2024 · 2 comments
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.

Comments

@LeaVerou
Copy link

LeaVerou commented Jul 28, 2024

This is a super low priority nice-to-have QoL addition, but thought I should probably open a new issue than try to stuff it into an "Oh and by the way" in #3386.

Most of my 11ty projects have an import like:

import * as filters from "./filters/index.js";

and a mass-add statement in the config:

for (let name in filters) {
	config.addFilter(name, filters[name]);
}

It would be nice if addFilter() supported aggregation: if you pass a whole object, simply add all values that are functions as filters, using their keys as names.
This would turn my little snippet into a single line:

config.addFilter(filters);

Or, you could use a separate name:

config.addFilters(filters);

And even for those defining filters inline in their config file, it would make the definitions far more readable:

config.addFilters({
	foo () {
		/* ... */
	},
	bar () {
		/* ... */
	},
	// ...
});
@nhoizey
Copy link
Contributor

nhoizey commented Jul 29, 2024

It would be great indeed.

I would in addition love a config.addFiltersGlob("**/filters/*.js") that would add filters defined in multiple files. (even better if the parameter can be an array of globs).

It would ease a lot what I've done there: 😅

https://github.com/nhoizey/eleventy-plugin-pack11ty/blob/main/eleventy-plugin-pack11ty.js#L67-L94

@zachleat zachleat added enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. labels Jul 30, 2024
@zachleat
Copy link
Member

By default this repo closes enhancement request issues and places them in a queue for folks to upvote. We do this to avoid a large build-up of open issues. We got this idea from the lodash project.

Don’t forget to upvote the first comment with 👍 to register your vote! You can view the current enhancement backlog.

@zachleat zachleat closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: 🛠 configuration Related to Eleventy’s Configuration file needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.
Projects
None yet
Development

No branches or pull requests

3 participants