I have create a method that given a string will find all interpolation points relative to a certain pattern some string {{point}} this is working however its not very elegant and I'm wondering if anyone knows of a cleaner more minified way of doing this?
Here is my method:
_interoplationPoints: function(string){
var startReg = /{{/gi,
endReg = /}}/gi,
indices = {start: [],end: []},
match;
while (match = startReg.exec(string)) indices.start.push(match.index);
while (match = endReg.exec(string)) indices.end.push(match.index);
return indices;
},
Given a string it will check for all start and end points {{ & }} it will then return an object with the start and end points of each occurance of {{}}.
The reason for me doing this is I will later substring() these indexes with there relevant value.
String.replaceing the placeholders in one go? The offsets will change once you start tosubstrin new values, so this is all quite messy it'd seem.some string {{value}}will be stored alongside the binding data which is referenced each timevalueis changed. The interpolation points are assigned on compile and reused with the original value to settextNode.nodeValue