11ty / eleventy-plugin-webc

Adds support for WebC *.webc files to Eleventy
https://www.11ty.dev/docs/languages/webc/
120 stars 10 forks source link

Render functions in layouts aren't re-processed through WebC #20

Closed darthmall closed 1 year ago

darthmall commented 2 years ago

If you use WebC for a layout, and have a render function that writes out another WebC component, the WebC component is not processed by WebC.

If you do the same thing in a page template, however, it works.

I've created a repo to reproduce the issue: https://github.com/darthmall/11ty-webc-render-function-layout-bug

zachleat commented 2 years ago

This will require https://github.com/11ty/webc/issues/51

I think we want to encourage folks to use webc:raw with @html in layout templates so that we can re-enable reprocessing mode in Layouts https://github.com/11ty/eleventy-plugin-webc/blob/cc118905bd9ba8f8d5e1154a6d9947789d355c38/src/incremental.js#L29

zachleat commented 1 year ago

This will ship with Eleventy WebC 0.7.0!

Notably, the breaking change is that using the following in an Eleventy layout will reprocess content as WebC (which means it will be double transformed by the page and the layout).

<template @raw="content"></template>

It’s recommended to use @raw in your Eleventy Layout file to avoid double-processing:

<template webc:nokeep @raw="content"></template>

Comment updated to add new @raw alias for webc:raw @html