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

Nunjucks and async filters - clearer documentation #2254

Closed
cfjedimaster opened this issue Mar 1, 2022 · 1 comment
Closed

Nunjucks and async filters - clearer documentation #2254

cfjedimaster opened this issue Mar 1, 2022 · 1 comment

Comments

@cfjedimaster
Copy link

cfjedimaster commented Mar 1, 2022

Unless I'm seeing wrong, while Nunjucks does support async filters, it does not support them if you do it via a global filter. I had this:

eleventyConfig.addFilter("qrcode", async function(value) {
		return await qrCode.toDataURL(value);
});

Which worked fine in Liquid, but returned a pending promise in Nunjucks. Adding this made it work in Nunjucks:

eleventyConfig.addNunjucksAsyncFilter("qrcode2", async function(value, callback) {
	let result = await qrCode.toDataURL(value);
	callback(null,result);
});

I guess my issue here is - it doesn't seem clear to me that the universal async filter should fail in Nunjucks. Can we add something to the doc (I'd say to both pages) to clarify this? (Willing to file a PR.)

@zachleat
Copy link
Member

https://www.11ty.dev/docs/filters/#asynchronous-universal-filters

@zachleat zachleat added this to the Eleventy 2.0.0 milestone Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants