MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / renderTemplate

Function renderTemplate

packages/app/src/response.ts:7–22  ·  view source on GitHub ↗
(_req: Request, res: Response, app: App)

Source from the content-addressed store, hash-verified

5import type { ReadStreamOptions, FormatProps, DownloadOptions } from '@tinyhttp/res'
6
7export const renderTemplate = <O>(_req: Request, res: Response, app: App) => (
8 file: string,
9 data?: Record<string, any>,
10 options?: TemplateEngineOptions<O>
11): Response => {
12 app.render(
13 file,
14 data,
15 (err: unknown, html: unknown) => {
16 if (err) throw err
17 res.send(html)
18 },
19 options
20 )
21 return res
22}
23
24export interface Response<O = any> extends ServerResponse {
25 header(field: string | Record<string, unknown>, val?: string | any[]): Response

Callers 1

extendMiddlewareFunction · 0.90

Calls 2

sendMethod · 0.80
renderMethod · 0.65

Tested by

no test coverage detected