nodejs 模板引擎ejs的简单使用(3)

1.ejs

<!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.js

var ejs=require('ejs');

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

输出效果:

 

 a.txt

努力吧
不管别人怎么看待你,
你都要坚持做自己

 

 

 

 

 

 

 



posted @ 2017-11-09 23:07  1点  阅读(303)  评论(0编辑  收藏  举报