maki-template
Version:
HTML-Style Express.js rendering engine
19 lines • 596 B
JavaScript
var check = [/</g,/>/g,/&/g,/"/g,/'/g,/</g,/>/g,/&/g,/"/g,/'/g];
exports.escape = function (str) {
str = String(str);
str = str.replace(check[2], "&");
str = str.replace(check[0], "<");
str = str.replace(check[1], ">");
str = str.replace(check[3], """);
str = str.replace(check[4], "'");
return str;
};
exports.unEscape = function (str) {
str = String(str);
str = str.replace(check[5], "<");
str = str.replace(check[6], ">");
str = str.replace(check[8], '"');
str = str.replace(check[9], "'");
str = str.replace(check[7], "&");
return str;
};