When I request data from my API, it returns JSON objects which then populate numerous divs with content. However, I find myself continuously using concatenation to insert object properties. Is there a more efficient method for achieving this?
$.each(JSON, function(key, value) {
var content = display_mention(value);
$("#mentions_container").append(content);
});
function display_mention(mention) {
//this str will be much more complex and use lots of concatenation
var str = "<div data-id='" + mention.id +"'>'" + mention.texto + "'</div></br>";
return str;
}