eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Using filters inside JS Data files eleventyComputed.js

Open mahnunchik opened this issue 2 years ago • 2 comments

Operating system

macOS 13.2.1

Eleventy

2.0.1

Describe the bug

If filter is used in JS data files then there is no this.page data.

// _data/eleventyComputed.js
module.exports = function() {
  return {
    // works
    bar: '{{ "bar" | myFilter }}',
    // doesn't work
    baz() {
      return this.myFilter('baz');
    },
  };
}

Reproduction steps

Complete example https://github.com/mahnunchik/test-11ty

Expected behavior

this.page inside filter is filled with correct data when is used in JS data files.

Reproduction URL

https://github.com/mahnunchik/test-11ty

Screenshots

No response

mahnunchik avatar Mar 28 '23 18:03 mahnunchik

Related issue: https://github.com/11ty/eleventy/issues/2135

mahnunchik avatar Mar 28 '23 18:03 mahnunchik

@zachleat could it be fixed in v3?

mahnunchik avatar Apr 04 '24 22:04 mahnunchik