4 ms·
Nope. Avoid. Switch to templates at the moment you think you need this kind of a solution. Use for example super comoact http://archan937.github.com/templayed.j
by atirip 14y ago
Nope. Avoid. Switch to templates at the moment you think you need this kind of a solution. Use for example super comoact http://archan937.github.com/templayed.js/ http://archan937.github.com/templayed.js/
Compared to almost full blown mustache implementation, pithy.js, surprise, is a bloat.
Sorry of being harsh, as a positive note, the code itself, in abstract way is my liking. Very good. May even steal some snippets.
- sophacles 14y agoAhh yes, the old "trusty-hammer" argument. Sometimes this exact sort of library is needed, and quite useful. More than once I've found myself doing single-tag or 2-tag templates and composing them in code, with bits for passing in class name or id, and later selecting them to change some property. Basically the use case for a library like this. Templates are useful, so are tag generation code snippets. Both go in my toolbox just fine.
- atirip 14y agoFor 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; }
- sophacles 14y agoOh, 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).
- atirip 14y agowhatever