themaster
themaster

Reputation: 385

Node EJS passing data to an include

Currently I'm messing around with Node and EJS templates.

However I have hit a problem. Im building up a page made up of multiple components and im calling these components into the index page like so:

<% include components/header.ejs %>

My question is how can I pass data (json) to that specific include?

I want to be able to reuse components however to show different content coming from json.

Thanks

Upvotes: 6

Views: 3858

Answers (1)

Alexandr Lazarev
Alexandr Lazarev

Reputation: 12892

Try:

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

Upvotes: 8

Related Questions