#HTML 'dsl' / lmth?

11 messages · Page 1 of 1 (latest)

distant hamlet
#

Hello,
I'm new to TypeScript and fairly new to web development.
I'm looking for a package or tool to generate HTML server-side and found lmth, which provides a solution I like, but it's deprecated.
Does anyone know of similar solutions?
I've been doing my early proof-of-concept work using Deno and Hono.

Thanks!

rapid heart
shadow gyro
#

I haven't had a chance to use Hono yet, but IIRC Hono has a JSX runtime to generate HTML directly.

distant hamlet
shadow gyro
#

If you are using Hono already, might as well just use their JSX.

distant hamlet
#

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.

shadow gyro
#

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.

distant hamlet
#

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.

shadow gyro
#

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.