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

WebC: Using getBundle() in a <style> or <script> tag always empty, but fine when used in, say, <div> #85

Open anghelos opened 1 year ago

anghelos commented 1 year ago

When trying to output the bundled CSS or JS in a .webc layout, the resulting tag is returned empty. I've tested that getBundle() outputs the proper code when used in an html tag other than <style> or <script>, however.

Edit: getBundleFileUrl() also works properly.

Example:

<script @raw="getBundle('js')" webc:keep></script>
<div @raw="getBundle('js')"></div>

Results in:

<script></script>
<div>(the proper javascript for the current page)</div>

I've tried troubleshooting by storing getBundle('js') to a variable in a webc:setup script (no change), replacing getBundle('js') with other text (works), as well as using webc:raw instead of webc:keep. I can't for the life of me figure out what I'm doing wrong.

I am using chained layouts, but from what I see that issue has been resolved (?)