简体   繁体   English

在EJS模板中包含一个名称在其变量中的视图文件

[英]include a view file that it's name is in a variable into an EJS template

I use this method to include an ejs file in my template: 我使用此方法在模板中包含一个ejs文件:

<% include header %>

But if header is a variable, I get some errors. 但是,如果header是变量,则会出现一些错误。 How i can include a file that it's name is in a variable into an ejs template? 我如何将文件名包含在ejs模板的变量中?

You can't: 您不能:

https://github.com/tj/ejs/issues/93 https://github.com/tj/ejs/issues/93

The issue was opened in 2013 and never resolved. 该问题于2013年开放,但从未解决。

However, in version 2 you call include as a plain function : 但是,在版本2中,您将include 作为普通函数调用

<%- include(header) %>

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

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