how to include a template with parameters in EJS?

后端 未结 4 2309
无人共我
无人共我 2020-12-09 14:39

As a real beginner in EJS, I have two charts in my html page, so I want to use my partial twice:

<% include partials/spider-chart.ejs %>
4条回答
  •  春和景丽
    2020-12-09 15:37

    @Naeem Shaikh solution works. Though include also gives you more intuitive way of including a partial template and also passing context variables to that as found in documention section of ejs.

      <% users.forEach(function(user){ %> <%- include('user/show', {user: user}); %> <% }); %>

提交回复
热议问题