Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. String.prototype.replaceAll = function(search, replacement) {
  2. return this.replace(new RegExp(search, 'g'), replacement);
  3. };
  4. app={
  5. dataToHtml:function(html,object){
  6. $.each(object,function(index,value){html=html.replaceAll('_'+index+'_',value);});return html;
  7. },
  8. renderHtmldata:function(template,data){
  9. this.htmlTemplate=$('#'+template).html();
  10. var html='';
  11. if(this.htmlTemplate){
  12. $.each(data,function(index,value){
  13. html=html+appdata.dataToHtml(appdata.htmlTemplate,value);
  14. });
  15. }
  16. console.log(html);
  17. return html;
  18. },
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement