JSFiddle - React, Tailwind, and code Playground
HTML
<div id="tweets"></div>
JavaScript
function nano(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function(str, key) {
var keys = key.split("."), v = data[keys.shift()];
for (i = 0, l = keys.length; i < l; _i++) v = v[this];
return (typeof v !== "undefined" && v !== null) ? v : "";
});
};
var template = "<p><b>@{from_user}</b><br>{text}</p>";
var query = "yellow submarine";
$.getJSON("http://search.twitter.com/search.json?callback=?", {q: query}, function(data) {
$.each(data.results, function(i, item){
$("#tweets").append(nano(template, item))
})
});