I'm working on an Express + EJS project and getting this error when rendering my invoice.ejs view:
TypeError: C:\Users\naray\OneDrive\Desktop\Invoice-saas\invoice-generator\views\invoice.ejs:17
>> 17| <%- include('partials/sidebar', { user: user, page: 'invoice' }) %>
include is not a function
I’ve already installed EJS and configured it in my Express app:
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
My folder structure looks like this:
views/
├─ partials/
│ └─ sidebar.ejs
└─ invoice.ejs
I’m trying to include a sidebar partial and pass some variables (user, page) to it. However, EJS throws include is not a function. I’ve tried both syntaxes:
<%- include('partials/sidebar', { user: user, page: 'invoice' }) %>
and
<%- include('partials/sidebar') %>
but the error persists.
What could be causing this, and how can I properly include partials with variables in EJS?
filenameoption for EJS?client? github.com/mde/ejs/issues/525