Open niklasgrewe opened 1 year ago
@usualoma i saw that you brought the html template literals to hono. Thanks for your effort. I really like to work with it because it is absolutely simple but also very performant and powerful.
What do you think about my idea to add components to html template literals as I explained above? Do you think this would be possible without losing simplicity and performance? Similar to you, I don't want html middleware to become "as complex" as jsx, but maybe there is a good middle ground.
I'm looking forward to your feedback.
Hi @niklasgrewe !
Thanks for the suggestion.
The ability to precompile the following features would be essential to implement and execute them in high performance. When dynamically parsing and executing HTML, it will be much slower than the current JSX.
Implementing it as third-party middleware might be an interesting challenge. Still, I don't think adding such functionality to the html
middleware included in the core is a good idea.
const home = () => html`
<h1>Homepage</h1>
<card>
<p>card content</p>
</card>
`
const card = () => html`
<div>
<slot></slot>
</div>
`
I think this is best for a plugin (e.g vite plugin) or just using web components!
What is the feature you are proposing?
I really like the
html
middelware for templating. It's faster thanjsx
and the code is more readable in my opinion. But can we extend this to support components like in other frameworks like astro or svelte? I imagine something like this:Instead of writing this:
we can write:
and with props:
To distinguish server-side components from native web components, I would personally consider three approaches:
unfortunately i don't know how complex it is to add such a feature to the html middleware or whether this will cause performance problems. Of course you can argue that we already got this feature through jsx middleware. However, jsx is slower and the writing doesn't feel as clean and native as html in my opinion. Also, it is easier for me to add
<style />
and<script />
tags, because you don't need to add thehtml
wrapper around this, also you do not need a fragment.Hope you like the idea. Am curious about your feedback