@anzaui/engine - v0.6.0
    Preparing search index...

    Class Fragment

    A fragment render request: validates the template and slot, then calls Engine.renderFragment and returns an Envelope for fetch responses and partial updates.

    The engine looks the template up in its cache, checks the fragments allowlist, binds params, stamps the current time and, when signing is on, signs the v2 message. A template outside the allowlist is reported exactly like a missing one (NOT_FOUND).

    Values are not HTML-escaped unless the engine runs with escape: true: escape untrusted input with escapeHtml before binding it.

    import { Fragment, jsonResponse } from '@anzaui/engine';

    const envelope = await new Fragment('feed/card.html', 'feed', {
    title: 'New Event Received',
    status: 'processed',
    }).run(engine);
    return jsonResponse(envelope);
    // {"v":2,"slot":"feed","ts":…,"html":"…","sig":"…"}
    Index
    • Parameters

      • template: string

        Template name relative to the root, e.g. feed/card.html.

      • slot: string

        The target name written into the envelope.

      • Optionalparams: Params

        Values for the template placeholders.

      Returns Fragment

    params?: Params

    Values for the template placeholders.

    slot: string

    The target name written into the envelope.

    template: string

    Template name relative to the root.

    • Validate and render the envelope.

      Parameters

      Returns Promise<Envelope>

      The (signed, when signing is on) envelope.

      AnzaError VALIDATION for an empty or malformed name or slot; NOT_FOUND for an unknown template or one outside the allowlist.