11ty / webc

Single File Web Components
MIT License
1.33k stars 39 forks source link

Syntax improvements to render functions #50

Closed zachleat closed 2 years ago

zachleat commented 2 years ago
  1. Make this for prop/data/attr reference optional. Similar to https://github.com/11ty/webc/issues/40 but for https://www.11ty.dev/docs/languages/webc/#webctyperender-(javascript-render-functions). See this.alt and this.src below:
<script webc:type="render" webc:is="template">
function() {
    if(!this.alt) {
        throw new Error("oh no you didn’t");
    }
    // Free idea: use the Eleventy Image plugin to return optimized markup
    return `<img src="${this.src}" alt="${this.alt}">`;
}
</script>
  1. Remove the function() altogether! Again reusing the work for #40
zachleat commented 2 years ago

This was solved by #73