H
Hono2d ago
dom

Passing `{...rest}` in the html`` tag

https://hono.dev/docs/helpers/html shows how you can use the spread operator to pass a bunch of generic props to a tag, but using JSX. We're all in on the html tagged literal, and I was wondering if its possible to do this using it? something like: <div ...${rest}>?
html Helper - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
5 Replies
ambergristle
ambergristle2d ago
it's just a string, so it'll behave as any template literal does you'd need to appropriately stringify + format key/value pairs yourself
dom
domOPthis hour
gotcha, is there no built-in helper for it?
ambergristle
ambergristle23h ago
not the way you mean you might be able to finesse something w the jsx helper, but idk if that's meant for consumer use
atoko
atoko21h ago
Jsx type in hono is “async () => string” so it’s likely to work. There’s a memo() that sounds like what you want
dom
domOP20h ago
thanks guys, will check it out tomorrow, will drop an update here in case anyone else is interested

Did you find this page helpful?