eg:

  var app={};

  app.tempEngine= (function () {
  var pattern = /\{(\w*[:]*[=]*\w+)\}(?!})/g;
  return function (template, json) {
  return template.replace(pattern, function (match, key, value) {
  return json[key];
     });
   }
})();

 

var template='<div>{name}</div>\

<div>{ege}</div>\

',data={

  name:"dabingzi",

      ege:28

}

 

$(app.tempEngine(template, data));

...../

...../

<div>dabingzi</div>\

<div>28</div>

 

相关文章:

  • 2021-08-15
  • 2021-07-25
  • 2021-10-21
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2021-11-16
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-12-21
相关资源
相似解决方案