Skip to content

escapeScriptTag

Import from @varavel/vdl-plugin-sdk/utils/strings.

function escapeScriptTag(str): string;

Escapes sequences that could prematurely close an HTML \<script> tag. Use this when injecting JSON data or raw strings into embedded scripts.

Parameters

Parameter Type Description
str string The string to escape.

Returns

string

The escaped string safe for embedding in a script tag.