Skip to content

Instantly share code, notes, and snippets.

@girvan
Created March 22, 2012 04:45
Show Gist options
  • Save girvan/2156101 to your computer and use it in GitHub Desktop.
Save girvan/2156101 to your computer and use it in GitHub Desktop.
function tmpl(tpl, pattern)
{
var find;
for(var i=0, n=pattern.length; i < n; i++)
{
find = new RegExp("\\{"+i+"\\}","g");
tpl = tpl.replace(find, pattern[i]);
}
return tpl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment