Setu-TS
    Preparing search index...

    Interface IViewEngine

    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.

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

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

    0.6.0

    interface IViewEngine {
        render<P>(component: Component<P>, props: P): string | Promise<string>;
    }
    Index
    • 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.

      Type Parameters

      • P

        The component's props bag

      Parameters

      • component: Component<P>

        The view component to render

      • props: P

        The props passed to the component

      Returns string | Promise<string>

      The rendered HTML, buffering before send — never a stream

      Implementations refuse a tree holding a pending <Suspense> boundary by name (buffered rendering would serve only the fallback forever) and wrap a component that throws

      0.6.0