code: function templateFunc(str, data) {
  
    const func = function(obj) {
      return str.replace(/<%=([^%]*)%>/g, match => {
        //match t("...")
        let s = match.match(/t\s*\(([^)]+)\)/g);
        //replace with translation
        if (s.length) {
          s = obj.t(s[0].match(/"([^"]+)"/g)[0].split('"').join(""));
        }
        //use object[name]
        else {
          s = match.match(/([a-z\-A-Z]+([a-z\-A-Z0-9]?[a-zA-Z0-9]?)?)/g)[0];
          s = obj[s] || s;
        }
        return s;
      });
    };
    // Figure out if we're getting a template, or if we need to
    // load the template - and be sure to cache the result.
    const fn = !/<[a-z][\s\S]*>/i.test(str) ? templates[str] = templates[str] || templateFunc(globals.templates[str]) : func;
  
    // Provide some basic currying to the user
    return data ? fn(data) : fn;
  }
docs: Based on Simple JavaScript Templating by John Resig generic templating function