Escapes HTML special characters from a template literal.

Parameters:
NameTypeDescription
templateDatastring

The template literal to be escaped.

Since
  • 1.0.0
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>`;
}