htmlEncode
Encode the string into HTML entities, converting special characters (such as <, >, &) to their corresponding HTML entities (e.g., <, >, &). This prevents these characters from being mistakenly interpreted as part of HTML tags by the browser.
Added in v0.0.1
Usage
ts
import { htmlEncode } from 'parsnip-kit'
htmlEncode('\'test\'') // ''test''
htmlEncode('"test"') // '"test"'
htmlEncode('<img/>') // '<img/>'
htmlEncode('talk & code') // 'talk & code'API
Arguments
| Arg | Type | Optional | Default | Description |
|---|---|---|---|---|
arg | any | false | undefined | The string to be converted. |
Returns
| Type |
|---|
string |