[英]EJS not able to render page due to class declaration
<header class="main-header">
<nav class="main-header__nav">
<ul class="main-header__item-list">
<li class="main-header__item"><a class="<%= path === '/' ? 'active' : '' %>" href="/">Shop</a></li>
<li class="main-header__item"><a class="<%= path === '/admin/add-product' ? 'active' : '' %>" href="/admin/add-product">Add Product</a></li>
</ul>
</nav>
When I try to render the page in my node js application I am getting an error.当我尝试在我的节点 js 应用程序中呈现页面时,出现错误。 Saying there is an error说有错误
I am not so used to writing ejs but when I remove the class="<%= path === '/'? 'active': '' %>"
in the navigation.ejs it seems to work我不太习惯编写 ejs,但是当我在 navigation.ejs 中删除class="<%= path === '/'? 'active': '' %>"
时,它似乎可以工作
Error Image错误图像
Use <%- include('RELATIVE/PATH/TO/FILE'); %>
使用<%- include('RELATIVE/PATH/TO/FILE'); %>
<%- include('RELATIVE/PATH/TO/FILE'); %>
to embed an EJS partial in another file. <%- include('RELATIVE/PATH/TO/FILE'); %>
将 EJS 部分嵌入到另一个文件中。
<%-
instead of just <%
tells EJS to render raw HTML.连字符<%-
而不仅仅是<%
告诉 EJS 呈现原始 HTML。;
并且还使用;
at end of include在包含末尾Here is an example...这是一个例子......
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head'); %>
</head>
<body class="container">
<header>
<%- include('../partials/header'); %>
</header>
<main>
<div class="jumbotron">
<h1>This is great</h1>
<p>Welcome to templating using EJS</p>
</div>
</main>
<footer>
<%- include('../partials/footer'); %>
</footer>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.