Replacing Placeholders In Email Template
What is the better way to replace placeholders in email module? So, I have made a mail service which takes parameters like templatename , receiverMail & locals. locals have the
Solution 1:
We can use regular expressions to search and replace the template with the user specified data.
I have put up a small demo at
Here I am replacing the template with the actual data.
I am using the below code for replacing the data in the template:
for (var i = 0; i < data.length; i++) {
var obj = data[i];
output +="<p>" + template.replace(/\<%=(.*?)\%>/g, function(match, property) {
return obj[property];
}) + "</p>";
}
Post a Comment for "Replacing Placeholders In Email Template"