Node.js 这个ejs在翡翠中会是什么样子?

Node.js 这个ejs在翡翠中会是什么样子?,node.js,pug,ejs,Node.js,Pug,Ejs,我正在学习如何构建简单的CRUD web应用程序,说明是用ejs编写的。然而,我刚刚开始学习jade,不知道如何将此ejs代码转换为jade <% layout( 'layout' ) -%> <h1 id="page-title"><%= title %></h1> <div id="list"> <form action="/create" method="post" accept-charset="utf-8">

我正在学习如何构建简单的CRUD web应用程序,说明是用ejs编写的。然而,我刚刚开始学习jade,不知道如何将此ejs代码转换为jade

<% layout( 'layout' ) -%>

<h1 id="page-title"><%= title %></h1>

<div id="list">
  <form action="/create" method="post" accept-charset="utf-8">
    <div class="item-new">
      <input class="input" type="text" name="content" />
    </div>
  </form>

<% todos.forEach( function ( todo ){ %>
  <div class="item">
    <a class="update-link" href="/edit/<%= todo._id %>" title="Update this todo item"><%= todo.content %></a>
    <a class="del-btn" href="/destroy/<%= todo._id %>" title="Delete this todo item">Delete</a>
  </div>
<% }); %>
</div>

所以你想知道如何用翡翠书写第二部分
每个
都是Jades迭代的主要方法之一。您的代码可以这样编写:

each todo in todos
  .item
    a(class="update-link" href="/edit/"+todo._id title="Update this todo item")= todo.content
    a(class="del-btn" href="/destroy/"+todo._id title="Delete this todo item") Delete

这里有一个关于迭代的jades文档链接:

I checked documents。我更有可能通过例子更好地理解。我被困在里面了,但我现在可以走得更远了。我很感激
each todo in todos
  .item
    a(class="update-link" href="/edit/"+todo._id title="Update this todo item")= todo.content
    a(class="del-btn" href="/destroy/"+todo._id title="Delete this todo item") Delete