类似于jsp,模板引擎

<% = 表达式%> 返回一个字符串

<% 表达式%> 执行js代码

模板文件render with jsonData

1
2
// load the template file, then render it with data
var html = new EJS({url: 'cleaning.ejs'}).render(data);

view helpers

1
2
3
4
5
<li>
<a href='supplies/<%= supplies[i] %>'>
<%= supplies[i] %>
</a>
</li>

用view helper:link_to 等价于上边

1
2
3
<li>
<%= link_to(supplies[i], 'supplies/'+supplies[i]) %>
</li>