Skip to main content
Module

x/dejs/escape.ts>default

ejs template engine for deno.
Extremely Popular
Go to Latest
function default
import { default } from "https://deno.land/x/dejs@0.1.2/escape.ts";

Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.

Note: No other characters are escaped. To escape additional characters use a third-party library like he.

Though the ">" character is escaped for symmetry, characters like ">" and "/" don't need escaping in HTML and have no special meaning unless they're part of a tag or unquoted attribute value. See Mathias Bynens's article (under "semi-related fun fact") for more details.

When working with HTML you should always quote attribute values to reduce XSS vectors.

Examples

escape('fred, barney, & pebbles') // => 'fred, barney, &amp pebbles'

Parameters

string: string

Returns

string

Returns the escaped string.