So, folks who build web sites, I just added this conditional syntax to Kitten HTML template strings. Thoughts?
(See third code example. The is().yes().no().endIs() function chaining. My goal is to provide an alternative to the JavaScript ternary operator thatās easier to read. Does this succeed? Any suggestions?)
https://codeberg.org/kitten/app#how-many-kittens-are-too-many-kittens
#interfaces #code #design
(See third code example. The is().yes().no().endIs() function chaining. My goal is to provide an alternative to the JavaScript ternary operator thatās easier to read. Does this succeed? Any suggestions?)
https://codeberg.org/kitten/app#how-many-kittens-are-too-many-kittens
#interfaces #code #design
masukomi
in reply to Aral Balkan • • •i don't like the .endIf - feels really awkward.
yes & no feel wrong because it's not a yes/no question it's a true/false question. it's introducing new terminology that isn't clearer than old. if sticking with that, then what about
isTrue().yes().no()
or
test().trueResult().falseResult()
Also, if thinking about how to better it, I can't help but think about simplicity of the lisp/scheme version (test true-result false-result)
Aral Balkan
in reply to masukomi • • •This is what I have at the momentā¦ any ideas?
https://codeberg.org/kitten/app/src/branch/main/src/Server.js#L244
app
Codeberg.orgmasukomi
in reply to Aral Balkan • • •BUT... overall looks fine
1. i think i want the option of `.is().yes()` (without `.no()`)
2. I feel like there "must" be a way to consolidate that code ...something something recursion? not sure.
Vancha :fedora:
in reply to masukomi • • •Not definitive, but I think a step in the right direction at least :)
Aral Balkan
in reply to Vancha :fedora: • • •Aral Balkan
in reply to Aral Balkan • • •So: kitten.if().then().else().endIf()
But Iām not sure if thatās better than is().yes().no().endIs() when reading it.
Vancha :fedora:
in reply to Aral Balkan • • •