New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax goals #259
Comments
HTM is for JSX and is highly optimized for that. It's recommended you avoid HTML quirks and stick to minimal JSX syntax. If you still need HTML you can have a look at xhtm. |
It's very much an attempt to provide a similar experience to authoring JSX in plain JS. A few HTML attributes are encouraged, but in general, the idea is to use JS properties.
You absolutely can. I'm not sure HTM is really the best at facilitating that, but you can get a pretty nice experience out of template literals & |
I'm looking for templates that work with Preact and support valid HTML, e.g. If it is capable of other proprietary stuff like Anyway, thanks for the replies. |
If you need actual HTML, The 'X' in JSX is XML. HTM is certainly closer to HTML than standard JSX, but if you want actual HTML, you're left with strings & reassembling yourself or using |
No I don't need that. I'm all good, I was just under the impression that HTM supported 100% valid HTML syntax. It's closer to HTML than JSX, like you said, and that's really nice, I just wish it went all the way. |
I'm new to htm. I like it. I chose it because it can be used with Preact in a no-build environment, i.e. our micro-frontend app will use
https://esm.sh/htm/preact/standalone
at runtime.However, I'm a bit confused as to whether htm wants to be more like HTML or JSX. The docs say JSX-like, but there's differences...and those differences seem to more align with vanilla HTML and JavaScript. Well, sort of.
I see support for
class
instead ofclassName
, which is great and I understand that's more of a Preact thing, but then I seeonClick
used here in the docs instead ofonclick
. Both work, and I prefer the HTML style, but it feels like htm doesn't know what it wants to be. This is made more confusing because void elements like<img>
don't work. You apparently have to self-close them as if this were XML. But then non-void elements like<div></div>
can be self-closed, which is not valid HTML.Are there docs of some kind that go into this in more detail? I feel like I'm gonna keep finding more gotchas like when you first start using JSX. Can't a dev just write some HTML anymore😭
The text was updated successfully, but these errors were encountered: