Git Product home page Git Product logo

Comments (5)

dy avatar dy commented on June 9, 2024

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.

from htm.

rschristian avatar rschristian commented on June 9, 2024

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.

Can't a dev just write some HTML anymore

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 & .innerHTML these days. Certainly are security risks, but, hard to beat stringified HTML if that's what you're after.

from htm.

jfbrennan avatar jfbrennan commented on June 9, 2024

I'm looking for templates that work with Preact and support valid HTML, e.g. class, onclick, <img>. Very much what the original goal of HTM apparently is/was: something that "felt natural for use untranspiled in the browser."

If it is capable of other proprietary stuff like <//> that's cool too, but I want to write valid HTML without having to think twice about it. HTM seems close enough, XHTM shared by @dy looks like it is maybe even closer...docs just don't say enough though.

Anyway, thanks for the replies.

from htm.

rschristian avatar rschristian commented on June 9, 2024

If you need actual HTML, __dangerouslySetInnerHTML might be the solution.

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 __dangerouslySetInnerHTML to pass these strings to Preact.

from htm.

jfbrennan avatar jfbrennan commented on June 9, 2024

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.

from htm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.