我想在一个电子邮件模板来替换占位符,继内作出功能是我的代码: -错误 - 不要循环
我收到error : Don't make functions within a loop
var dataPlaceholders = [{
"username":"John Johny",
"website":"w3schools . com"
}];
template_html = "<b>Hello <%= username %>,</b><br/><br/> You are successfuly Registered on xyz.<br/><br/>Thank you <%= website %>";
函数调用: -
function ReplacePlaceholders(dataPlaceholders, template_html){
for (var i = 0; i < dataPlaceholders.length; i++) {
var obj = dataPlaceholders[i];
template_html += "" + template_html.replace("/<%=%>/g", function (match, property) {
return obj[property];
}) + "";
}
return template_html;
}
感谢您的帮助。
为了帮助你*什么*?错误消息明确指出错误 – zerkms
@Zerkms我得到了1个新错误:在创建一个新函数后....错误:在调用构造函数时缺少新的前缀 – Anup
你知道什么http://google.com是什么? – zerkms