简体   繁体   English

节点EJS将数据传递给include

[英]Node EJS passing data to an include

Currently I'm messing around with Node and EJS templates. 目前我正在搞乱Node和EJS模板。

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? 我的问题是如何将数据(json)传递给特定的包含?

I want to be able to reuse components however to show different content coming from json. 我希望能够重用组件,以显示来自json的不同内容。

Thanks 谢谢

尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM