escape
Converts the characters & < > " ' in a string to their corresponding HTML entities. For example, '<' becomes '<'.
When inserting a string whose content is not known in advance into HTML markup, it prevents the string from being interpreted as a tag or attribute boundary. Backticks (`) and slashes (/) are ordinary characters to the HTML parser, so they are not converted.
Code
Interface
typescript
function escape(str: string): string;
Usage
typescript
import { escape } from '@modern-kit/utils';
escape('This is a <div> element.'); // 'This is a <div> element.'
escape('This is a "quote"'); // 'This is a "quote"'
escape("This is a 'quote'"); // 'This is a 'quote''
escape('This is a & symbol'); // 'This is a & symbol'
// Returns the original string if there is nothing to convert
escape('상품 12개'); // '상품 12개'