#HTML 'dsl' / lmth?
11 messages · Page 1 of 1 (latest)
have you considered react server components? https://react.dev/reference/rsc/server-components
I haven't had a chance to use Hono yet, but IIRC Hono has a JSX runtime to generate HTML directly.
I have not but let me take a look.
If you are using Hono already, might as well just use their JSX.
Hi @shadow gyro Thanks for the reply. I've looked at the JSX solution, but I really like the approach Lmth used, as it follows the same pattern as PSHTML for PowerShell, which I have the most experience with.
I've never liked the pattern of putting code in the middle of HTML text, but I think I may have to go with it anyway.
I'm not familiar with the concept, can you elaborate? To me l.div(...) doesn't seem much different than jsx('div', ...), which is what JSX <div>...</div> compiles to.
All the JSX example I have see look like this where you write out the html driectly.
return (
<html>
<body>{props.children}</body>
</html>
)
}```
The way my brains wants to work is link this:
``` function Layout(stuff) {
return (
html(
body(
stuff
)
)
)
}
But i will take another look at JSX.
Yeah JSX is basically just syntax sugar that compiles from the former to the latter.
The latter was how people wrote things back then, and JSX was invented so people can now write the former instead. The major benefit is that you can more or less copy existing HTML straight into JS and it will work with minimal changes. This enables a bunch of stuffs like, use browser dev tools to modify/debug your page, and when it's good you just copy it straight back to your code.