There's no way to opt out of rendering a component entirely.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 46
- Avg merge
- 10m
- Merged PRs (30d)
- 2
Description
@11ty/eleventy: 2.0.0
@11ty/eleventy-plugin-webc: 0.9.0
<!-- index.webc -->
<is-lang :lang="meta.locale.lang" is="es">
<h1>Hola!</h1>
</is-lang>
<is-lang :lang="meta.locale.lang" is="en">
<h1>Hello!</h1>
</is-lang>
<is-lang :lang="meta.locale.lang" is="fr">
<h1>Bonjour!</h1>
</is-lang>
<!-- components/is-lang.webc -->
<script webc:setup>
function isLang(inputLang, targetLang) {
inputLang = String(inputLang).toLowerCase();
targetLang = String(targetLang).toLowerCase();
return inputLang && targetLang && (inputLang === targetLang);
}
</script>
<slot webc:if="isLang(lang,is)"></slot>
Output (e.g. meta.locale.lang === 'fr'):
<h1>Hola!</h1>
<h1>Hello!</h1>
<h1>Bonjour!</h1>
Instead of the expected output:
<h1>Bonjour!</h1>
If I add the following line to the end of is-lang.webc, it looks visually correct, but of course, outputs unnecessary markup.
<span webc:if="!isLang(lang,is)"></span>
Outputs:
<span></span>
<span></span>
<h1>Bonjour!</h1>
I believe webc:if should be respected on slots so the redundant inverted "if" is not needed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the behavior shown in components/is-lang.webc and reproduce the example using the three language variants. Trace how webc:if on the slot is rendered; done means nonmatching components produce no output or placeholder markup, leaving only the matching h1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100