5 ms·
<template> tags are so incredibly useful for keeping your JS clean when you're not able to have something more reactive around for some reason. I've recently u
by pretzelhands 4y ago
<template> tags are so incredibly useful for keeping your JS clean when you're not able to have something more reactive around for some reason.
I've recently used that on an interview project I did (https://github.com/pretzelhands/ubiquitous-sniffle https://github.com/pretzelhands/ubiquitous-sniffle) and it surprisingly takes you quite far with very little effort.
The only major annoyance is really manually keeping track of the elements in the DOM and .innerText and .innerHTML-ing everything that needs a dynamic value. But it's manageable if you keep it confined.
- wildrhythms 4y agoThis approach always seems so easy at first glance, but I find it gets rather unwieldy as soon as I need to update some deeply nested value- like updating a innerText in cell in a table in a card in a layout of a thousand cards without re-rendering the entire collection. I started using lit-html and it solves this problem (and only costs me 3KB or so to ship).
- akrymski 4y agoI've used this approach in my minimal MVC lib for over a decade, simply using hidden elements instead of templates http://krymski.com/espresso.js/ http://krymski.com/espresso.js/
- ohmahjong 4y agoIs the demo site still supposed to be up? I see > TypeError: path must be absolute or specify root to res.sendFile when I try to visit it.