easierbycode
11/4/2011 - 12:57 AM

templates

templates

/**
 * Render templates.
 *
 * @param {String} The template to use `<p>Hello {{name}}</p>`
 * @param {String} The data `{ name: 'Alex' }`
 * @return {String} The rendered template
 **/
function template(t, d) {
  return t.replace(/{{([^}]*)}}/g, function(m, f, p, a) {
    return d[f] || '';
  });
};