Skip to content

eleventyConfig.augmentFunctionContext to add this.eleventy and this.page to the context of any function (but mostly for filters/shortcodes) #3355

@zachleat

Description

@zachleat

Sample usage here creating a Nunjucks shortcode from scratch:

eleventy/test/EleventyTest.js

Lines 1435 to 1445 in 26d26b7

let fn = eleventyConfig.augmentFunctionContext(
eleventyConfig.getShortcode("customized"),
{
source: context.ctx,
// lazy: false,
// getter: (key, context) => context?.[key];
// overwrite: true,
}
);
return fn(argString);

Related to #3310 and noelforte/eleventy-plugin-vento#9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions