Node EJS passing data to an include

北战南征 提交于 2019-12-07 01:57:13

问题


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


回答1:


Try:

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


来源:https://stackoverflow.com/questions/34622011/node-ejs-passing-data-to-an-include

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!