I have quite a few templates that use mustache tags to determine where to place user data. These templates are stored as a string.
When I call the render function in my mustache, I pass in a complex JSON object that contains several arrays of both strings and nested documents.
I incorrectly declared in the mustache tag to use a specific element in the array as follows:
{{dataElementArray[2].subElement}} {{anotherElement.dataArray[1]}}
Instead, I would like to change all occurrences within each template to the correct mustache syntax to address such elements:
{{dataElementArray.2.subElement}} {{anotherElement.dataArray.1}}
What is the best way to systematically go through each pattern (represented as a string) and use a regular expression to change what each tag has? I have over 50 templates, most of which contain hundreds of lines with hundreds of tags in each of them.
I am using JavaScript / Node.js for this application.
source share