Client side and Server side rendering of ejs template

后端 未结 3 1333
深忆病人
深忆病人 2020-12-20 02:42

I always wanted to learn NodeJS to be able to run the same code on server and client side. I am using NodeJS with Express and EJS. So. I have a .ejs page with lot\'s of HTM

3条回答
  •  生来不讨喜
    2020-12-20 03:25

    As per ejs templates documentation

    var template = new EJS({
      text: `
        
      <% for(i = 0; i < the_list.length; i++) { %>
    • the_list[i]
    • <% } %>
    ` }); var html = template.render({ the_list: data }); document.getElementById('list-wrapper').innerHTML = html;

提交回复
热议问题