[英]Could not find matching close tag for “<%” error when I try to include the file
When I try to include other .ejs files using the same syntax everything is working perfectly except when I include my _show.ejs file.I dont know where the actual is in the index.ejs or _show.ejs file.当我尝试使用相同的语法包含其他 .ejs 文件时,一切正常,除非我包含我的 _show.ejs 文件。我不知道实际在 index.ejs 或 _show.ejs 文件中的位置。
My index.ejs File我的 index.ejs 文件
<!-- include header -->
<%- include('include/_header') %>
<!-- /include header -->
<!-- Main Site -->
<main id="site-main">
<div class="container">
<div class="box-nav d-flex justify-between">
<a href="/add-user" class="border-shadow">
<span class="text-gradient">New User <i class="fas fa-user"></i></span>
</a>
</div>
<!-- form handling -->
<form action="/" method="POST">
<table class="table">
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Name</th>
<th>@Email</th>
<th>Gender</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%- include('include/_show') %>
</tbody>
</table>
</form>
</div>
</main>
<!-- /Main Site -->
<!-- include footer -->
<%- include('include/_footer') %>
<!-- /include footer -->
_show.ejs file saved in include folder _show.ejs 文件保存在包含文件夹中
<% for(var i = 0; i < users.length; i++) { %>
<tr>
<td><%= i + 1 %></td>
<td><%= users[i].name %></td>
<td><%= users[i].email %></td>
<td><%= users[i].gender %></td>
<td><%= users[i].status %></td>
<td>
<a
href="/update-user?id=<%= users[i]._id%>"
class="btn border-shadow update"
>
<span class="text-gradient"><i class="fas fa-pencil-alt"></i></span>
</a>
<a class="btn border-shadow delete" data-id="<%" ="users[i]._id%">
<span class="text-gradient"><i class="fas fa-times"></i></span>
</a>
</td>
</tr>
<% } %>
Error错误
26| </thead>
27| <tbody>
>> 28| <%- include('include/_show') %>
29| </tbody>
30| </table>
31| </form>
Could not find matching close tag for "<%".找不到与“<%”匹配的结束标记。 at在
at Array.forEach (<anonymous>)
at Template.generateSource (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:730:15)
at Template.compile (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:585:12)
at Object.compile (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:396:16)
at handleCache (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:233:18)
at includeFile (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:321:10)
at include (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:690:16)
at eval (eval at compile (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:662:12), <anonymous>:15:17)
at index (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:692:17)
at tryHandleCache (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:272:36)
at View.exports.renderFile [as engine] (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/ejs/lib/ejs.js:489:10)
at View.render (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/express/lib/view.js:135:8)
at tryRender (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/express/lib/application.js:640:10)
at Function.render (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/home/sonwar/Desktop/Programming/NodeJS/crud_app/node_modules/express/lib/response.js:1012:7)```
I think you lose some code.我想你丢失了一些代码。 In "_show.ejs" file,在“_show.ejs”文件中,
From -从 -
<a class="btn border-shadow delete" data-id="<%" ="users[i]._id%">
To -到 -
<a class="btn border-shadow delete" data-id="<%= users[i]._id%>">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.