eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Warn users if they use {% include %} in Liquid templates (or update docs to deprecate {% include %})

Open AleksandrHovhannisyan opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I recently ran into the issue I filed here a while back: https://github.com/11ty/eleventy/issues/2000.

At first I thought maybe Liquidjs had regressed, but then I saw my comment at the end noting that this was only fixed for the {% render %} tag, not for {% include %} (which is now deprecated). See comment here: https://github.com/harttle/liquidjs/issues/404#issuecomment-955660149

include and layout are legacy tags which does not provide Context separation. In both Shopify/Liquid and LiquidJS, {% assgin %} in {%include%} files assigns to its parent template, thus will not hide include arguments. So it's by design and that's why {%include%} tag is deprecated.

Describe the solution you'd like

If a user's template language is set to Liquid and they use {% include %}, it would be nice if we could log a warning in the server console noting that this tag is deprecated and may not behave as expected. Otherwise, a user's template may fail silently.

I'm not sure if this is actually possible, though, because 11ty doesn't know when you use a particular tag, right? That's just the template language's job.

Describe alternatives you've considered

  1. Documentation updates to prominently deprecate {% include %}: https://www.11ty.dev/docs/languages/liquid/#supported-features
  2. Add a new config option in liquidjs that allows you to alias {% include %} to {% render %} under the hood. And then 11ty could set this to true by default.

Additional context

Would be happy to work on this if you think it's a worthwhile enhancement.

AleksandrHovhannisyan avatar May 27 '22 18:05 AleksandrHovhannisyan