Monday 29 May 2017

EJS dynamic include

I am trying to dynamicly include one of my partials, using EJS. I render a template like so:

Router

router.get('/', noteController.getNotes, (req, res, next) => {
    return res.render(template{'page':'all'})
})

And am trying to include a partial in this template, based on the variable "page".

template.ejs

<% include %><%= page %><% .ejs %>

This however does not work. I have tried multiple methods, to no avail. Any help is much appreciated.



via n0rd

No comments:

Post a Comment