eleventy
eleventy copied to clipboard
Normalize signature of `this` in callbacks that operate on templates
Thinking https://www.11ty.dev/docs/config/#transforms and linters and before callback in Pagination (#1209).
This will be important before 1.0 release to avoid any breaking changes.
I’d like the metadata available in this to be consistent here. Specifically this.page.inputPath instead of this.inputPath. See https://www.11ty.dev/docs/data-eleventy-supplied/
There are likely others—I don’t have time to compile them all here right this second but we’ll need to look through and find them all.
Related to https://github.com/11ty/eleventy/issues/338 (and https://github.com/11ty/eleventy/issues/130)
There are two styles in play here:
Collection-style:
- inputPath, fileSlug, outputPath, url, date, data (full data cascade), templateContent
Template-style:
- inputPath, fileSlug, outputPath, url, and date go through
page - full data cascade and templateContent are not available in some cases
ACTION ITEMS
- [x] Surface
pagein collection-style entries for more consistency (while keeping backwards compatibility). This would solve some of the issues in #338 (but not top leveldataandcontent) - [x] Surface
pagein Linters - [x] Surface
pagein Transforms - [x] Surface
pagein Filters - [x] Shortcodes (this is already done—you can use this.page on Handlebars, Liquid, 11ty.js, Nunjucks)
After this last analysis I don’t think this is a blocker for 1.0. Moving it out of the milestone.
Filters/helpers shipped with #2250
this.page is available on Shortcodes, Filters, Linters, Transforms in 2.0.0-canary.19 and newer
page and content (aliased to templateContent) is available on Collections items on 2.0.0-canary.19 and newer. https://www.11ty.dev/docs/collections/#collection-item-data-structure
Time to move to the 2.x branch I guess!
Cross linking the shortcode work that shipped with v0.11.0 #741