Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 12, 2024
1 parent 3e61cf1 commit c37011e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/jsx/jsx-dev-runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
export * from 'hono/jsx/jsx-dev-runtime'
import { type JSXNode, jsx } from 'hono/jsx'
import type { HtmlEscapedString } from 'hono/utils/html'
export { Fragment } from 'hono/jsx'

export function jsxDEV(
tag: string | Function,
props: Record<string, unknown>,
key?: string,
): JSXNode {
let node: JSXNode
if (!props || !('children' in props)) {
node = jsx(tag, props, ...[])
} else {
const children = props.children as string | HtmlEscapedString
// biome-ignore lint/performance/noDelete:
// biome-ignore lint/complexity/useLiteralKeys:
delete props['children']
node = Array.isArray(children)
? jsx(tag, props, ...children)
: jsx(tag, props, ...[children])
}
node.key = key
return node
}
9 changes: 8 additions & 1 deletion src/jsx/jsx-runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export * from 'hono/jsx/jsx-runtime'
export { jsxDEV as jsx, Fragment } from '../jsx-dev-runtime/index.js'
export { jsxDEV as jsxs } from '../jsx-dev-runtime/index.js'

import { html, raw } from 'hono/html'
export { html as jsxTemplate }
export const jsxAttr = (name: string, value: string) =>
raw(`${name}="${html`${value}`}"`)
export const jsxEscape = (value: string) => value

0 comments on commit c37011e

Please sign in to comment.