4 ms·
A generalization of this is to avoid string concatenation in favor of building up a proper internal representation of the data and then serializing it. See als
by mwcampbell 14y ago
A generalization of this is to avoid string concatenation in favor of building up a proper internal representation of the data and then serializing it.
See also: Data In, Garbage Out (http://glyph.twistedmatrix.com/2008/06/data-in-garbage-out.html http://glyph.twistedmatrix.com/2008/06/data-in-garbage-out.h...)
- deleted 14y ago[deleted]
- threedaymonk 14y agoThat's a good post that I hadn't seen before. Thanks. It's a matter of continuing puzzlement to me that, despite the fact that more robust and better-abstracted methods of producing output exist, the dominant paradigm in web development is to concatenate strings together and hope. But it's worse than that: many people actively reject better methods on the basis that, as I've heard it expressed over and over, you "should" be able to just write HTML, ipse dixit. There's active resistance to improving this awful situation. I don't understand it. I wish I did.
- rdw 14y agoString concatenation is usually way faster both at runtime and at code-time than the alternatives.
- homakov 14y agoRJS is fast but not secure. Trade off?
- dopamean 14y agoI am currently building a web app and I've found myself doing a lot of string concatenation. What are these more robust and better-abstracted methods? I would love to read up on them. Thanks.
- nickzoic 14y agoDo you mean doing things (in jQuery) like: $('<div id="' + identifier + '">' + some_text + '</div>'); If so, consider doing: $('<div>').attr('id', identifier).text(some_text); which handles escaping correctly for you. Or equivalent in your preferred JS framework or lack of framework.