Skip to content
Myr

feat(jsx-renderer): pass the context as 2nd arg (#2459)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* feat(jsx-renderer): pass the context as 2nd arg * denoify

authored by Yusuke Wada · committed by GitHub · parent 84bcbe8 · Browse files · 3 files+53 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+53 added−18 removed

  • tests:+23 added−0 removed
  • other:+30 added−18 removed

3 files+53 added−18 removed

modified:deno_dist/middleware/jsx-renderer/index.ts+15 added-9 removed
modified:src/middleware/jsx-renderer/index.test.tsx+23 added
54 unmodified lines
55 '<!DOCTYPE html><div class="nested"><h1>http://localhost/nested</h1></div>'56 )57 })5859 it('Should get the context object as a 2nd arg', async () => {60 const app = new Hono()61 app.use(62 jsxRenderer(63 ({ children }, c) => {64 return (65 <div>66 {children} at {c.req.path}67 </div>68 )69 },70 { docType: false }71 )72 )73 app.get('/hi', (c) => {74 return c.render('hi', { title: 'hi' })75 })7677 const res = await app.request('/hi')78 expect(res.status).toBe(200)79 expect(await res.text()).toBe('<div>hi at /hi</div>')80 })8182 it('nested layout with Layout', async () => {83 const app = new Hono()84 app.use(85 '*',
373 unmodified lines
modified:src/middleware/jsx-renderer/index.ts+15 added-9 removed