/** Supplant **/
String.prototype.supplant = function(o) {
return this.replace (/{([^{}]*)}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
);
};
Crockford is no doubt a JavaScript Grand Wizard, but his prototype is lacking when it comes to multiple level objects.
I would like this function to cover multiple level object replacement such as '{post.detailed}' could anyone help me with a revised version of supplant?