I'm working on a function to search through an objects properties, and replace 'handle bar' values in a string.
Question
How do I change the following code to replace {{phones.primary}} with its value.
function template(content, values) {
for(prop in values) {
content = content.replace('{{' + prop + '}}', values[prop]);
}
return content;
}
alert(template('Hello {{name}}. Your primary number is {{phones.primary}}', {
name: 'Mickey Mouse',
phones: {
primary: '123-123-1234'
}
}));