最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Include partial with ejs - Stack Overflow

programmeradmin2浏览0评论

I'm trying to include a menu in my page with this code:

<%- include ../mon/menu %>

Here is the file directory: /views/mon/menu.ejs

Here is my menu.ejs:

<div class="button" id="menu-btn">
    <a class="btn-open" href="#"></a>
  </div>
  <div class="overlay">
    <div class="wrap">
      <ul class="wrap-nav">
        <li>
          <a href="/">Wele Page</a>
          <ul>
            <li>
              <a href="/main">Main Page</a>
            </li>
            <li>
              <a href="/vungtau">Vũng Tàu</a>
            </li>
            <li>
              <a href="/suoimo">Đồng Nai - Suối Mơ</a>
            </li>
            <li>
              <a href="/dalat">Đà Lạt</a>
            </li>
            <li>
              <a href="/video">Video</a>
            </li>
          </ul>
      </ul>
    </div>
  </div>

I got a 500 Internal Server Error but I did not know why? I'm following this tutorial:

I did many search on google but it s no help.

I'm trying to include a menu in my page with this code:

<%- include ../mon/menu %>

Here is the file directory: /views/mon/menu.ejs

Here is my menu.ejs:

<div class="button" id="menu-btn">
    <a class="btn-open" href="#"></a>
  </div>
  <div class="overlay">
    <div class="wrap">
      <ul class="wrap-nav">
        <li>
          <a href="/">Wele Page</a>
          <ul>
            <li>
              <a href="/main">Main Page</a>
            </li>
            <li>
              <a href="/vungtau">Vũng Tàu</a>
            </li>
            <li>
              <a href="/suoimo">Đồng Nai - Suối Mơ</a>
            </li>
            <li>
              <a href="/dalat">Đà Lạt</a>
            </li>
            <li>
              <a href="/video">Video</a>
            </li>
          </ul>
      </ul>
    </div>
  </div>

I got a 500 Internal Server Error but I did not know why? I'm following this tutorial: https://scotch.io/tutorials/use-ejs-to-template-your-node-application

I did many search on google but it s no help.

Share Improve this question asked May 3, 2018 at 15:45 Nguyen Hoang VuNguyen Hoang Vu 8634 gold badges18 silver badges38 bronze badges 1
  • You should accept solution for this answer. – Prathamesh More Commented Apr 2, 2020 at 4:34
Add a ment  | 

3 Answers 3

Reset to default 4

try this

<%- include('../mon/menu.ejs') %>

docs http://ejs.co/#docs

If I use this folder structure:

../views/partials/header.ejs
../views/partials/footer.ejs
../views/users.ejs

then in users.ejs:

<%- include('./partials/header.ejs') %>
<body>
...
</body>
<%- include("./partials/footer.ejs") %>

Try to use this new syntax

<%- include("partials/header") %>
<%- include("partials/footer") %>
发布评论

评论列表(0)

  1. 暂无评论