Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

TrustedHtml

tipo Since 1.3.0

Un string de HTML que el código declaró de confianza con trustHtml: el tipo que espera la directiva html="expresión" para no avisar con MEEK107.

La marca sólo existe en los tipos: en ejecución es el mismo string, así que se serializa en JSON tal cual y llega a la plantilla con la marca intacta desde <script server>, load o ServerData<T>. Un TrustedHtml se puede usar donde se espera un string, pero no al revés.

La marca no sanea nada: sólo dice que alguien comprobó el origen del HTML. Márquelo donde nace (el renderizador de Markdown propio, el resultado de un saneador como DOMPurify), no justo antes de la plantilla.

ts
import type { TrustedHtml } from "@meekojs/meeko";

Source code src/shared/trusted-html.ts:42

Declaración #

ts
type TrustedHtml = string & { readonly [trustedHtmlBrand]: true }

Example #

ts
import { trustHtml } from "@meekojs/meeko";
import type { TrustedHtml } from "@meekojs/meeko";

export interface Article {
  readonly title: string;
  readonly body: TrustedHtml;
}

export function article(title: string, html: string): Article {
  // `html` sale de nuestro propio renderizador de Markdown.
  return { title, body: trustHtml(html) };
}

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/shared/trusted-html.ts