Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何将车把转换为ejs_Node.js_Handlebars.js_Ejs - Fatal编程技术网

Node.js 如何将车把转换为ejs

Node.js 如何将车把转换为ejs,node.js,handlebars.js,ejs,Node.js,Handlebars.js,Ejs,这可能是一个简单的问题,但我想不出来 我想把这个把手代码改成ejs {{#if hasErrors}} <div class="alert alert-danger"> {{#each messages}} <p>{{ this }}</p> {{/each}} </div> {{/if}} {{{#if hasrerrors} {{{#每条消息} {{t

这可能是一个简单的问题,但我想不出来

我想把这个把手代码改成ejs

  {{#if hasErrors}}
  <div class="alert alert-danger">
  {{#each messages}}
                <p>{{ this }}</p>
            {{/each}}
        </div>
    {{/if}}
{{{#if hasrerrors}
{{{#每条消息}
{{this}}

{{/每个}} {{/if}
我试过了,但语法错误

 <%= if (Errors) {%>
 <div class="alert alert-danger">
 <%= each messages %>
 <p><%= this%></p>
 </div>
 <% }%>

如果您的“hasError”变量是布尔类型,并且您的messages变量是消息字符串数组

<% if (hasErrors) {%>
 <div class="alert alert-danger">
     <% messages.forEach(function(message){ %>
       <p><%= message %></p>
     <% });%>
 </div>
<% }%>