I am trying to create a super simple template for JavaScript. I want to use the JavaScript method replaceto find all instances of curly braces in a template and replace them with the corresponding data.
For example, if my template was: <p>My name is {{name}}. I am {{age}}.</p>
I need the result: <p>My name is Olly. I am 19.</p>
Here is my code: http://jsfiddle.net/2RkAG/
I'm trying to automatically replace every piece of data, so I don’t need to explicitly tell JavaScript what to replace. However, this is where I have problems.
user1082754
source
share