我正在开发 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/