MCPcopy
hub / github.com/11ty/buildawesome / addAsyncFilter

Method addAsyncFilter

src/UserConfig.js:443–462  ·  view source on GitHub ↗
(name, callback)

Source from the content-addressed store, hash-verified

441
442 // Liquid, Nunjucks, and JS only
443 addAsyncFilter(name, callback) {
444 // namespacing happens downstream
445 this.#add(this.universal.filters, name, callback, {
446 description: "Universal Filter",
447 functionName: "addAsyncFilter",
448 });
449
450 this.addLiquidFilter(name, callback);
451 this.addJavaScriptFilter(name, callback);
452 this.addNunjucksAsyncFilter(
453 name,
454 /** @this {any} */
455 async function (...args) {
456 let cb = args.pop();
457 // Note that `callback` is already a function as the `#add` method throws an error if not.
458 let ret = await callback.call(this, ...args);
459 cb(null, ret);
460 },
461 );
462 }
463
464 /*
465 * Shortcodes

Callers 4

addFilterMethod · 0.95
eleventyHtmlBasePluginFunction · 0.80
eleventyRenderPluginFunction · 0.80

Calls 4

#addMethod · 0.95
addLiquidFilterMethod · 0.95
addJavaScriptFilterMethod · 0.95

Tested by

no test coverage detected