diff --git a/examples/templating/index.html b/examples/templating/index.html index 6aeeac2..fb8ac4c 100644 --- a/examples/templating/index.html +++ b/examples/templating/index.html @@ -1,12 +1,17 @@ - + WC demo + +

With our html

+
+

With lit-html

+ diff --git a/examples/templating/with-lit.js b/examples/templating/with-lit.js new file mode 100644 index 0000000..fa568a0 --- /dev/null +++ b/examples/templating/with-lit.js @@ -0,0 +1,55 @@ +import { WebComponent } from "../../src/index.js"; +import { + html, + render as lit, +} from "https://unpkg.com/lit-html@3.1.0/lit-html.js"; + +export class LitCounter extends WebComponent { + static props = { + count: 123, + }; + get template() { + const list = ["a", "b", "c", "what"]; + const links = [ + { + url: "https://ayco.io", + text: "Ayo Ayco", + }, + { + url: "https://ayco.io/gh/McFly", + text: "McFly", + }, + ]; + + return html` + +
+ + +
+ ${list.map((item) => html`

${item}

`)} +

Links

+ + `; + } + render() { + lit(this.template, this); + } +} + +customElements.define("lit-counter", LitCounter);