-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renderTemplate inside of markdown fails to render WebC component properly #22
Comments
Hmmmmmmmmmm… I may need a reduced test case for this one. I created an automated test and could not get it to fail like you reported. Can you try to run the test I added to the repo locally? https://github.com/11ty/eleventy-plugin-webc/tree/main/test/render-plugin |
Maybe related to #16! Please re-test after Eleventy WebC v0.7.0 is released! Likely in the next few days |
New versions are released! I’d love some help with a retest! @11ty/eleventy@v2.0.0-canary.18 |
Edit: the issue of the processing step kicking out component content is fixed as of v2.0.0-canary.18. The below only applies to v.1.0.x. Using new version of eleventy-plugin-webc, I can still reproduce the buggy behavior. Try modifying the existing test in the following way:
# Hello
{% renderTemplate "webc" %}
<my-component webc:keep></my-component>
{% endrenderTemplate %}
<h2>My component</h2> Expected: <h1>Hello</h1>
<my-component>
<h2>My component</h2>
</my-component> Actual: <h1>Hello</h1>
<p>
<my-component></my-component>
</p>
<h2>My component</h2> In the above case, you can just omit There is a workaround: wrap <span>
{% renderTemplate "webc" %}
<my-component webc:keep></my-component>
{% endrenderTemplate %}
</span>
This also works:
{% renderTemplate "webc" %}
<span>
<my-component webc:keep></my-component>
</span>
{% endrenderTemplate %} Tested with: |
This is fixed in eleventy v.2.0.0! Although I am still seeing what I'd say is undesirable behavior (I would expect Input: # Hello
{% renderTemplate "webc" %}
<my-component webc:keep></my-component>
{% endrenderTemplate %} Expected Output: <h1>Hello</h1>
<my-component><h2>My component</h2></my-component> Actual Output: <h1>Hello</h1>
<p><my-component><h2>My component</h2></my-component></p> The workaround from before (wrapping custom elements in another top-level HTML element) still works for now, but isn't ideal. |
The extra paragraph seems to be a general markdown2 thing which also has ongoing discussion: michelf/php-markdown#230 Maybe Eleventy/webc should filter out any wrapped p tags as part of {%renderTemplate "webc" %} ? |
This occurs in this scenario as well (v2.0.1):
index.html (liquid template)
some-test.webc:
Result:
Also, using the same |
i think this is still an issue even with eleventy 3 if you mention the component in-line. renders right: <some-button></some-button> kicks the content out: hello <some-button></some-button>! workaround (renders some-button inline, doesn't kick out content): <div/> hello <some-button></some-button>! |
I'm experiencing a version of this same problem and I'm not sure if it's just broken, or if I'm using this feature totally wrong. Context: I write all my blog posts in Markdown, and I'd like to use <script>
const canvas = document.getElementById('example1');
const ctx = canvas.getContext('2d');
canvas.width = 360;
canvas.height = 200;
ctx.fillStyle = '#ff0000';
ctx.fillStyle = '#4b3b9c';
ctx.fillRect(0, 0, 360, 200);
</script>
<canvas id="example1"></canvas>
<style>
#example1 { border: solid 3px #00ff00; }
</style> And then I want to insert it in my Markdown post, which apparently I need to wrap in a render call: {% renderTemplate "webc" %}
<example1></example1>
{% endrenderTemplate %} This works, but my So then I try to force it to run, by adding Am I misunderstanding how to use WebC in this way? |
One update: I finally found an example of what I'm trying to do, in the section https://www.11ty.dev/docs/languages/webc/#use-with-is-land : <!-- JS -->
<script type="module" webc:keep>
console.log("This JavaScript runs on:visible");
</script> As written, it works, but if you try adding a second line it all falls apart: <script type="module">
console.log("This JavaScript runs on:visible");
<p>console.log("Here is a second line");
</script> |
Describe the bug
When using
renderTemplate
to allow a WebC component within a markdown page, the effect of markdown processing adds extra paragraphs and breaks the WebC rendering by kicking out the content.To Reproduce
renderTemplate
Expected behavior
my-component
is replaced with the simple paragraph of content from the component.Actual behavior
Element is no longer correctly replaced and is also wrapped in a paragraph, and WebC content is kicked out
Environment:
Additional context
Not being able to render in markdown is limiting for including WebC as enhanced features within blog/long-form content which is a popular way to use Eleventy.
The text was updated successfully, but these errors were encountered: