nodejs ejs include unexpected identfier

i'm using nodejs + express + ejs and i am having a problem when i try to include another view.

When I try:

<% include dochead %>

I get 'unexpected identifier';
when i try:

<% include /admin/global/dochead %>

I get 'include is not defined';

What is going on? Thanks

Upvotes: 6

Views: 1005

Answers (2)

Mohit Soni
Mohit Soni

Reputation: 21

Try

<%- include ('dochead') %>

or

<%- include ('admin/global/dochead') %>

set

app.set('view engine', 'ejs');
app.set('views', 'YOUR CUSTOM VIEW FOLDER PATH FROM ROOT FILE');

Upvotes: 1

Bohdan Leseiko
Bohdan Leseiko

Reputation: 85

I think here <% include /admin/global/dochead %> should be

<% include ../admin/global/dochead %>

or

<% include admin/global/dochead %>

depending on the location. Also check the view engine you use

app.set('view engine', 'ejs');

Upvotes: 0

Related Questions