Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 325
EspeH Avatar asked Oct 30 '22 04:10

EspeH


1 Answers

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

like image 77
Sorskoot Avatar answered Nov 12 '22 16:11

Sorskoot