how to include a template with parameters in EJS?

后端 未结 4 2340
无人共我
无人共我 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:12

    This is the best workaround by just passing the view file name as a context while rendering the base ejs file.

    /base.ejs:

    
        <%- include(content) %>
    
    

    /extra.ejs:

    some content which is to be added in base ejs file

    /controller.js:

    res.render('base', { content: 'extra' })
    

提交回复
热议问题