Node EJS passes data to include

I am currently messing around with Node and EJS templates.

However, I ran into a problem. I create a page consisting of several components, and I call these components on the index page as follows:

<% include components/header.ejs %> 

My question is, how can I pass data (json) for this particular one?

I want to be able to reuse components, however, to display other content coming from json.

thanks

+5
source share
1 answer

Try:

 <%- include('components/header.ejs', {data: 'data'}); %> 
+5
source

Source: https://habr.com/ru/post/1239935/


All Articles