jade/pug Is it possible to use variables on include statement?

扶醉桌前 提交于 2019-12-11 03:17:01

问题


I'm developing nodejs application and I have issue with include statement. It works when I use it like this:

include ../mixins/root.pug

...but is it possible to use variables on include?

None of these work:

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

Result is this:

Error: ENOENT: no such file or directory

回答1:


Dynamic includes are not supported:

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



来源:https://stackoverflow.com/questions/37094986/jade-pug-is-it-possible-to-use-variables-on-include-statement

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