Escapes HTML special characters from a template literal.
Parameters:
Name | Type | Description |
---|---|---|
templateData | string | The template literal to be escaped. |
- Since
- 1.0.0
- Source
Returns:
Returns the template string, with HTML special characters escaped.
- Type:
- string
Example
import { saferHtml } from "@gravityforms/utils";
function Example() {
const str = 'my encoded <b>bold</b> text';
const encodedString = saferHtml`<div>${ str }</div>`;
}