Skip to content

Instantly share code, notes, and snippets.

@watagashi
Created September 8, 2011 13:15
Show Gist options
  • Save watagashi/1203362 to your computer and use it in GitHub Desktop.
Save watagashi/1203362 to your computer and use it in GitHub Desktop.
Online Study TokyoBouldering.js – Lingr http://lingr.com/room/tkbjs/
Function.prototype.method = function (name, func) {
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
String.method('entityify', function () {
var character = {
'<' : '&lt;',
'>' : '&gt;',
'&' : '&amp;',
'"' : '&quot;'
};
return function () {
return this.replace(/[<>&"]/g, function (c) {
return character[c];
});
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment