我是在客户端尝试 ejs 模板。在使用 include 指令时,用它包含 header.ejs 这个文件到一个html页面里,header.ejs 和 html 在同一目录:
header.ejs 代码如下:
<h1 id="title">页面标题</h1>
我首先使用了:
<%- include('header.ejs') %>
好,给我报了一个错:include
requires the filename
option.
接着我使用另外一种写法:
<%- include header.ejs %>
但又给我报了一个另外的错:include
requires the filename
option.
我在使用 include 前,用 for 和 if else 指令,都能正常渲染数据。
但就是这个 include 试了很多次,也看了些网上和github的资料,都没能正常显示!(⊙﹏⊙)b,请问下,有人知道这个东西,到底怎么用的吗?
最新版的客户端ejs include引入其他ejs文件 需要使用<%- include('filename') -%>才能成功的引入。