概述
What is the “E” for? “Embedded?” Could be. How about “Effective,” “Elegant,” or just “Easy”? EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow. It’s just plain JavaScript.
简言之,EJS
就是高效的可嵌入的JavaScript
模版引擎,用在从JSON
对象数据中生成HTML
字符串,即是HTML = Template + Data
。
const ejs = require('ejs');
const templateEngines = ['jade', 'ejs'];
const template = '
<ul>
<% templateEngines.forEach((engine) => {
%>
<li>
<span><%= engine %></span>
</li>
<% }) %>
</ul>
';
const