Please people... keep your HTML out of your javascript
What if we'd had better HTML-in-JS syntax all along?
91–100 of 170 posts
Re: What if we'd had better HTML-in-JS syntax all along?
#92This sort of thing is easy in Lisp: https://edicl.github.io/cl-who/
Re: What if we'd had better HTML-in-JS syntax all along?
#93I think the JSX is just fine as an HTML-in-JS syntax. You can use JSX independently of React. Here's a 200-line library that lets you use JSX as a templating language just like Handlebars: https://github.com/wisercoder/uibuilder
What's the issue with web components that they have never took off?
The main use right now is as target for framework independent design systems / component libraries.
Re: What if we'd had better HTML-in-JS syntax all along?
#94The solution is not another templating language. Html is complex and many templating languages exist because it’s hard to compress and everything thinks it’s not that hard. There are so many things you need to do in HTML to make a modern web page that this suggestion conveniently ignores. The web is complex because it has replaced native programs and it’s perfectly backwards compatible. Stop trying to make it look ea…
Any examples of things that aren't handled by the suggested syntax?
Re: What if we'd had better HTML-in-JS syntax all along?
#95The "object" syntax reminds me a lot of Clojure/script's Hiccup ( https://github.com/weavejester/hiccup ) style, which has become a de-facto standard across many popular libraries. In hiccup, this example: { tag: "button", attributes: { "id": "baz", "class": "foo bar", "data": "1", "onclick": f, }, children: [ "Hello", { tag: "em", attributes: {}, children: ["there"], } ] } Would be represented as: [:button#baz.foo.b…
Re: What if we'd had better HTML-in-JS syntax all along?
#96Earlier quoted context omitted.
What's the issue with web components that they have never took off?
Besides the poor browser support (supporting IE11 is still quite a pain) the API is just so bad that you'll need another abstraction on top anyway. The main use right now is as target for framework independent design systems / component libraries.
Looks pretty straightforward, and there isn't much of an API to begin with. It's just plain HTML, CSS, JavaScript and DOM APIs.
Re: What if we'd had better HTML-in-JS syntax all along?
#97Earlier quoted context omitted.
> PHP code which supports being interspersed with HTML You're one of a large number of people who say this, but it is false. PHP intersperses a programming language with static strings. Those static strings frequently adhere to HTML syntax, but that's aside from PHP. What is HTML? It's not random strings; it's a syntax. JSX is much closer to interspersing HTML with a Turing-complete programming language than PHP ever…
You're technically correct, but I don't think the distinction adds anything to the conversation. I don't know if PHP was the inspiration for JSX, but if the strings they were using in PHP was HTML, then it could have been. EDIT: Sounds like JSX was inspired by XHP: https://www.facebook.com/notes/facebook-engineering/xhp-a-ne...
Re: What if we'd had better HTML-in-JS syntax all along?
#98Re: What if we'd had better HTML-in-JS syntax all along?
#99i also renamed my "className" to "cn" so i dont have to type it but i wouldn't recommend that.
h 'div',
cn: 'myclass'
h 'span',{},"mytext"
h 'span,{},"asd"Re: What if we'd had better HTML-in-JS syntax all along?
#100Earlier quoted context omitted.
You can also take a look at mithril.js implementation of hyperscript [0] [0] https://github.com/MithrilJS/mithril.js/blob/next/render/hyperscript.js
was about to mention Mithril. solid framework, but not great for large applications.