javascript - jade/pug 是否可以在 include 语句中使用变量?

标签 javascript node.js include pug pugjs

我正在开发 nodejs 应用程序,我对 include 语句有疑问。 当我这样使用它时它会起作用:

include ../mixins/root.pug

...但是可以在 include 上使用变量吗?

这些都不起作用:

include #{process.env.MIXINS_PATH}/root.pug
include !{process.env.MIXINS_PATH}/root.pug
include `${process.env.MIXINS_PATH}/root.pug`

结果是这样的:

Error: ENOENT: no such file or directory

最佳答案

不支持动态包含:

We don't support "Dynamic Include". There are lots of issues people have opened about this. It's really complex to implement and not actually nearly as useful as people think it would be.

https://github.com/pugjs/pug/issues/2622#issuecomment-270157667

关于javascript - jade/pug 是否可以在 include 语句中使用变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37094986/

相关文章:

javascript - 在关键字前添加字符串 - javascript

javascript - Jit Tree JS 和 Assets 预编译错误

c++ - Node js 我可以从用 C++ 编写的 Windows 命令行应用程序中获取退出代码吗?

javascript - 无法使用http模块nodejs azure函数执行http请求

c++ - 如何在 Code::Blocks 中包含 "custom"库? (Windows 7的)

c# - 使用 javascript 打开 PDF

javascript - VueJS 2 : Catch event of direct child component

javascript - 下载 billboard hot 100(但只有 50 个)mp3 文件

php - 在index.php(Fat-Free Framework)中包含文件

尝试编译 gstreamer 应用程序时 #include <anyfile.h> 的 C++ 问题