interface IViewEngine
Since 0.6.0

View engine contract — renders a view component and its props to HTML.

Registered under CAPABILITIES.VIEW ('view'). Every entry point reaches the SAME engine instance: the @Render decorator resolves it once at register() and the free renderView function resolves it per request, so an application's configured engine and options govern both.

The return is a union because an async component's render genuinely is a promise — the async arm is required, not speculative.

Examples

Example 1

import { CAPABILITIES } from '@setu-ts/common';

const engine = ctx.services.get<IViewEngine>(CAPABILITIES.VIEW);
const html = await engine.render(UserList, { users });

Methods

Since 0.6.0
render<P>(
component: Component<P>,
props: P
): string | Promise<string>

Renders a view component with the given props to an HTML string.

Interpolations are escaped by the RENDERING RUNTIME — the JSX runtime and the html tagged template both escape — and a component opts out with hono's own raw(), never with engine-level configuration.

The escaping is therefore a property of how a component is WRITTEN, not a guarantee this port makes. A plain (props) => string component is a valid Component and its output is returned unchanged: correct for a by-name engine whose compiled template has already escaped its own interpolations, and an XSS hole for a hand-written template literal such as (p) => `<p>${p.name}</p>` . Prefer JSX or the html tag; reach for a plain string only when the producer already escaped.

Usage

import { type IViewEngine } from "common/src/index.ts";