eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Normalize signature of `this` in callbacks that operate on templates

Open zachleat opened this issue 4 years ago • 2 comments

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.

zachleat avatar Nov 21 '20 00:11 zachleat

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 page in collection-style entries for more consistency (while keeping backwards compatibility). This would solve some of the issues in #338 (but not top level data and content)
  • [x] Surface page in Linters
  • [x] Surface page in Transforms
  • [x] Surface page in Filters
  • [x] Shortcodes (this is already done—you can use this.page on Handlebars, Liquid, 11ty.js, Nunjucks)

zachleat avatar Sep 28 '21 15:09 zachleat

After this last analysis I don’t think this is a blocker for 1.0. Moving it out of the milestone.

zachleat avatar Sep 29 '21 14:09 zachleat

Filters/helpers shipped with #2250

zachleat avatar Dec 14 '22 21:12 zachleat

this.page is available on Shortcodes, Filters, Linters, Transforms in 2.0.0-canary.19 and newer

zachleat avatar Dec 14 '22 22:12 zachleat

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

zachleat avatar Dec 14 '22 23:12 zachleat

Time to move to the 2.x branch I guess!

nhoizey avatar Dec 15 '22 09:12 nhoizey

Cross linking the shortcode work that shipped with v0.11.0 #741

zachleat avatar Dec 15 '22 15:12 zachleat