workplus-escape

Escape or unescape string for use in HTML.

Usage no npm install needed!

<script type="module">
  import workplusEscape from 'https://cdn.skypack.dev/workplus-escape';
</script>

README

workplus-escape npm

Toggle escape string and object for use in HTML.

Install

npm install --save workplus-escape

Usage

import { 
    escapeString,
    unescapeString,
    escapeObject,
    unescapeObject 
} from 'workplus-query-string';

const str = escapeString('<h1></h1>"');
// str => '&lt;h1&gt;&lt;/h1&gt;&quot;'

const rts = unescapeString('&lt;h2&gt;&lt;/h2&gt;');
// rts => '<h2></h2>'

let someObject = {
    a: '<h1></h1>',
    b: "'",
    c: {
        x: '""'
    }
};
let obj = escapeObject(someObject);
// obj.a => '&lt;h1&gt;&lt;/h1&gt;'
// ibj.b => '&#39;'
// obj.c.x => '&quot;&quot;'

let jbo = unescapeObject(obj);
// jbo.a => '<h1></h1>'

Why not use "&apos;"

Development

git clone https://github.com/WorkPlusFE/workplus-escape.git

npm install

npm test

License

MIT