3 ms·
I'm doing a small project. I'm experimenting with a pure JS/HTML/CSS approach. 1. Doing "myElement.innerHTML = `...`" is sufficient for the low-hanging fruit t
by lelanthran 2y ago
I'm doing a small project. I'm experimenting with a pure JS/HTML/CSS approach.
1. Doing "myElement.innerHTML = `...`" is sufficient for the low-hanging fruit that most jsx gets used for.
2. I also have a `Fluent()` function that returns an object with attrSet/attrRemove/classAdd/etc functions, which each also return the same object. It lets me do something like:
var el = Fluent('div')
.attrSet('disabled')
.classAdd('waves btn btn-small')
.idSet('MyNewElement')
.push(Fluent('div')
.attrSet('...'))
.attachTo(document.querySelector('#SomeParent');
So far, I'm not liking the second one much, and the first one is really hard to compose, but they're both useful for when you don't want a build-step.
- jampekka 2y agoWith coffeescript you can easily do with a dead-simple createElement wrapper something like: el = @div disabled: true, class: 'waves btn btn-small', id: 'MyNewElement', @div ...
- boredtofears 2y agoHow is that better than jsx?
- jampekka 2y agoIt doesn't need a new language and has a lot less noise. Loops and control structures work normally without extra syntax.
- boredtofears 2y agoCoffeescript is a new language though?
- lelanthran 2y agoI think coffeescript requires a build step. If I already had a build-step, then sure, I can throw a few things at the wall and see what sticks. For stuff that doesn't have a build-step, adding a build-step just to get an alternative to using the backticks seems like overkill.