You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[email protected] was released today and they now expose their filter implementations, so it looks like you can now use eleventyConfig.addNunjucksFilter() to add liquidjs filter implementations.
ProbablyAlmost certainly not a good idea, and probably not worth documenting, but a neat little hack if you're a Nunjucks user who is envious of some of them sweet, sweet filters.
// Where liquidjs is v9.9.0+, per https://github.com/harttle/liquidjs/issues/188const{ Liquid }=require("liquidjs");// console.log(require("liquidjs/package.json").version); // 9.9.0constliquidOptions={extname: ".liquid",strictFilters: true,root: ["_includes"]};constliquidEngine=newLiquid(liquidOptions);constliquidFilters=liquidEngine.filters.impls;module.exports=function(eleventyConfig){// eleventyConfig.setLibrary("liquid", liquidEngine);eleventyConfig.addNunjucksFilter("uniq",liquidFilters.uniq);return{dir: {input: "src",output: "www"}};};
Next I'll have to see if Nunjucks exposes filters in a way that they could be consumed by Liquid templates.
It's still a pretty fragile workflow, and not sure it'd be any better if somebody could repackage this into an Eleventy plugin where liquidjs filters get shimmed into nunjucks without all this hassle, but... I still figure this is a hacky solution and probably not worth the hassle of building something that would need to be maintained for more than 1 user.
The text was updated successfully, but these errors were encountered:
[email protected] was released today and they now expose their filter implementations, so it looks like you can now use
eleventyConfig.addNunjucksFilter()
to add liquidjs filter implementations.ProbablyAlmost certainly not a good idea, and probably not worth documenting, but a neat little hack if you're a Nunjucks user who is envious of some of them sweet, sweet filters.And now, in your Nunjucks templates, behold!
Next I'll have to see if Nunjucks exposes filters in a way that they could be consumed by Liquid templates.
It's still a pretty fragile workflow, and not sure it'd be any better if somebody could repackage this into an Eleventy plugin where liquidjs filters get shimmed into nunjucks without all this hassle, but... I still figure this is a hacky solution and probably not worth the hassle of building something that would need to be maintained for more than 1 user.
The text was updated successfully, but these errors were encountered: