Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / index / view

Function: view()

Call Signature

view(markup, status?): void

Defined in: helpers/response.ts:295

Render a view as the current response. Accepts either pre-rendered markup, or a view component plus its props — in which case the component receives the active request's HttpContext (route params and model bindings live on ctx.params) and the props you pass as a second argument.

Parameters

markup

string | { toString: string; }

status?

number

Returns

void

Example

// component + props — the request HttpContext is passed automatically:
view(Welcome, { title: "Welcome to Zerotal" });

// pre-rendered markup:
view(<Welcome title="Hi" />);

Call Signature

view<P>(component, props?, status?): void | Promise<void>

Defined in: helpers/response.ts:296

Render a view as the current response. Accepts either pre-rendered markup, or a view component plus its props — in which case the component receives the active request's HttpContext (route params and model bindings live on ctx.params) and the props you pass as a second argument.

Type Parameters

P

P extends Record<string, unknown> = Record<string, never>

Parameters

component

(ctx, props) => ViewMarkup | Promise<ViewMarkup>

props?

P

status?

number

Returns

void | Promise<void>

Example

// component + props — the request HttpContext is passed automatically:
view(Welcome, { title: "Welcome to Zerotal" });

// pre-rendered markup:
view(<Welcome title="Hi" />);