I use this little helper in my underground lab:
function template(str,data){
for(var i in data){
str=str.replace(new RegExp("{("+i+")}","g"),data[i])
}
return str
}
It can be used with arrays and object literals as well: txt = template('hello {name}!',{name:'Jen'})
txt = template('days: {0}, {1} and {2}',['mon','tue','wed'])
GPL and WTFPL just in case.* Looks coincidentally similar to Fuchs'