nodejs 模板引擎ejs的簡單使用(3)

1.ejshtml

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <% for(var i=0;i<2;i++){ %>
    <% include ../a.txt %>
    <% } %>
  </body>
</html>

ejs.jsui

var ejs=require('ejs');

ejs.renderFile('./views/1.ejs', {}, function (err, data){
  console.log(data);
});

輸出效果:spa

 

 a.txtcode

努力吧
無論別人怎麼看待你,
你都要堅持作本身
相關文章
相關標籤/搜索