在 ejs-locals 标头块中添加 header.ejs 文件

Eve*_*een 5 javascript ejs node.js express

我不知道是否可行,所以请给我一个建议。我的问题是如何在ejs-locals标题块内添加(包含) header.ejs ?

样板文件.ejs

<!DOCTYPE html>
<html>
  <head>
    <title>It's me</title>
    <%-scripts%>
    <%-stylesheets%>
  </head>
  <body>
    <header>
      <%-blocks.header%>
    </header>
    <section>
      <%-body -%>
    </section>
    <footer>
      <%-blocks.footer%>
    </footer>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

索引.ejs

<% layout('boilerplate') -%>
<% script('foo.js') -%>
<% stylesheet('foo.css') -%>

<h1>I am the  template</h1>
<p class="better-than-dead">I'm red if foo.css was loaded.</p>
<p>Here are some muppets we know about:</p>

<% block('header', "<p>I'm in the header.</p>") -%>
<% block('footer', "<p>I'm in the footer.</p>") -%>
Run Code Online (Sandbox Code Playgroud)

标头.ejs

<p>I'm in the header</p>
Run Code Online (Sandbox Code Playgroud)

在上面的代码(index.ejs)中,您可以看到 header 块具有 HTML 代码。但是我想包含 header.ejs。

谢谢。