angular clone
by Darby Rathbone
HTML
username: {username}</br>password: {password}
<br/>
<br/>{a}
JavaScript
var list = {},
re = /(\{)(\w+)(\})/gi;
document.body.innerHTML = document.body.innerHTML.replace(re, function (m, $1, $2) {
if (!list.hasOwnProperty($2)) {
list[$2] = $2;
Object.defineProperty(this, $2, {
get: function () {
return list[$2];
},
set: function (e) {
list[$2] = e;
[].splice.call(document.getElementsByClassName($2), 0).forEach(function (g) {
g.innerHTML = e;
});
}
});
}
return "<span class='" + $2 + "'></span>";
});
a= 'anything';
username = "blackkbot";
password = "secret";
test = "testing";