3 ms·
render("{a} is all that I've {a}", {'a' : 'b'}); "b is all that I've b" render("{a} is all that I've {{a}}", {'a' : 'b'}); SyntaxError: Unexpected token {
by alexgartrell 14y ago
render("{a} is all that I've {a}", {'a' : 'b'});
"b is all that I've b"
render("{a} is all that I've {{a}}", {'a' : 'b'});
SyntaxError: Unexpected token {
Seems Legit
- vain 14y agolooks like something broke in copying and pasting. try: http://pastebin.com/txM6NZBS http://pastebin.com/txM6NZBS
- deleted 14y ago[deleted]
- pfraze 14y agofunction render(tpl,data){ var matches = tpl.match(/{[^\}]+}/g); for(var i in matches){ var rep = eval("data."+matches[i].replace(/[{}]/g,'')); tpl = tpl.replace(matches[i],rep); } return tpl; } Fixed