Jump To …

test.js

test/

Escape the given html.

Params
html String- string to be escaped
Returns
Stringescaped html
See
API
public

Examples

utils.escape('<script></script>')
// => '&lt;script&gt;&lt;/script&gt;'
exports.escape = function(html){
  return String(html)
    .replace(/&(?!\w+;)/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;');
};

Escape the given html.

Params
html String- string to be escaped
Returns
Stringescaped html
Type
number
See
exports.escape
API
public

Examples

utils.escape('<script></script>')
// => '&lt;script&gt;&lt;/script&gt;'
exports.escape2 = function(html){
  return String(html)
    .replace(/&(?!\w+;)/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;');
};

generated Wed Nov 16 2011 07:50:53 GMT-0700 (MST)