问题
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