Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/vento/deps.ts>html.escape

🌬 A template engine for Deno & Node
Very Popular
Go to Latest
function html.escape
import { html } from "https://deno.land/x/vento@v0.11.0/deps.ts";
const { escape } = html;

Escapes text for safe interpolation into HTML text content and quoted attributes

Examples

Example 1

import { escape } from "https://deno.land/std@0.224.0/html/entities.ts";
import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts";

assertEquals(escape("<>'&AA"), "&lt;&gt;&#39;&amp;AA");

// characters that don't need to be escaped will be left alone,
// even if named HTML entities exist for them
assertEquals(escape("þð"), "þð");

Parameters

str: string

Returns

string