Overview
Escapes HTML special characters (&, ', `, ", <, >) in a string.
Import
import {utils} from 'metronic-extension';
const {escapeHTML} = utils;
Signature
escapeHTML(str: string): string
| Parameter |
Type |
Description |
str |
string |
String to escape. |
Returns: string — Escaped string.
Example
<div class="mb-3">
<label class="form-label">Input value</label>
<input id="escapeHTMLInput" class="form-control form-control-solid" placeholder="Enter text with HTML characters...">
</div>
<div>
<span class="fw-bold">Result: </span>
<code id="escapeHTMLResult"></code>
</div>
import {utils} from 'metronic-extension';
const {escapeHTML} = utils;
escapeHTML('I <b>think</b> this is good.');
// 'I <b>think</b> this is good.'
escapeHTML('John "Johnny" Smith');
// 'John "Johnny" Smith'