Escape Html Tags
escapeHtmlTags(input) ⇒ string
Escape special characters in the given string of text.
This function will escape the following characters: ", ', &, <, and >.
Kind: global function
| Param | Type | Description |
|---|---|---|
| input | string |
The string to escape for inserting into HTML |
The escapeHtml function is designed to accept a string input of text and return an escaped value.
const escapeHtml = require('escape-html')
// example values
const str = 'Escaping <i>html</i> works fine.'
// example passing text in span element
console.log('<span name="desc">' + escapeHtml(str) + '</span>')
// -> '<span name="desc">Escaping <i>html</i> works fine.</span>'