Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/html/mod.ts>escape

The Deno Standard Library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function escape
import { escape } from "https://deno.land/std@0.222.1/html/mod.ts";

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

Examples

Example 1

import { escape } from "https://deno.land/std@0.222.1/html/entities.ts";

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.
escape("þð"); // "þð"

Parameters

str: string

Returns

string