←back to thread

217 points palmfacehn | 1 comments | | HN request time: 0.254s | source
Show context
EGreg ◴[] No.45107545[source]
What exactly is the point of <template> tag? Just to create document fragments? I mean that’s all you can really do with it in HTML. If you are using JS you can attach shadow dom to any element.

I guess maybe slots for web components is the other point?

replies(4): >>45107642 #>>45108238 #>>45109718 #>>45111635 #
65 ◴[] No.45111635[source]
Alpine.js uses <template> tags for if statements and for loops with stateful data. E.g. <template x-if="myVariable === 1"><div>1</div></template>

Which is a simpler way of thinking about templates, rather than slots and fragments.

replies(2): >>45111759 #>>45115973 #
1. EGreg ◴[] No.45115973[source]
Why not just use handlebars js?