-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Add support for 11ty.js Virtual Templates #3347
Comments
Shipping with 3.0.0-alpha.15. Pass in the raw JavaScript as the virtual template content, like so: eleventyConfig.addTemplate("virtual.11ty.js", function(data) {
return `this is a test ${data.page.url}.`;
});
eleventyConfig.addTemplate("virtual.11ty.js", {
data: () => ({ var: 2 }),
render: function(data) {
return `this is a test ${data.var}.`;
}
}); |
Awesome! So, I guess using JS classes as templates (with import MyTemplateClass from 'mytemplate.js';
const template = new MyTemplateClass({ options: { /* ... */}});
eleventyConfig.addTemplate('virtual.11ty.js', template); |
@VividVisions any of the 11ty.js types would work there: https://www.11ty.dev/docs/languages/javascript/ |
Temporary docs preview URL building here: https://11ty-website-git-v3-11ty.vercel.app/docs/virtual-templates/#javascript |
Related: #1612
The text was updated successfully, but these errors were encountered: