Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For your case this is all what you need: function replace(str, data) { for( var i in data ) str = str.replace('{'+i+'}', data[i]); return str; }


Oh, now I see the light. I don't even need templates, just dozens of str.replaces littered throughout my code. Now I can throw away all these weird screw things, and just have nails!

/sarcasm

My point still stands, no matter what you think you read in my post, different tools for different jobs is OK, there is no "silver bullet" (or magic-hammer or whatever).


whatever




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: