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
Try:
<%- include('components/header.ejs', {data: 'data'}); %>
来源:https://stackoverflow.com/questions/34622011/node-ejs-passing-data-to-an-include