Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 627
themaster Avatar asked Jan 05 '16 22:01

themaster


1 Answers

Try:

<%- include('components/header.ejs', {data: 'data'}); %>
like image 105
Alexandr Lazarev Avatar answered Oct 15 '22 09:10

Alexandr Lazarev