Closed mizok closed 2 years ago
The problem is that it is not supported when using variable in include
function in ejs.
@dc7290 Obviously the reason is bc we are using regex to get the included files, but I am not sure if there is any way for this condition.
@mizok This is a difficult problem.
This is because we are using a combination of ejs and webpack mechanisms, and it is difficult to incorporate the dependencies that ejs internals recognize.
For now, I came up with the following solution.
include
path, register it with that function.We think the drawback is that it forces the user to do a somewhat tedious task.
- Add a function that allows users to add dependencies to the functions available in the ejs file.
- When you use a variable in the
include
path, register it with that function.
It is tedious to me... you are right.
Describe the bug
I am not sure if this should be regarded as a bug. I found this problem last week, this happened when I used
include
within afor
orforEach
loop inejs
, just like this:the problem was that webpack devserver did not recognize those partial ejs files as dependency, and I thought I could tell the reason, bc we were actually using regex to detect all
include
function insideejs
files, which means passing variable toinclude
function is not fully supported.But I still have no idea how to fix this..., I saw there was a
includer
option in the ejs npm package, which is capable of customize the originalinclude
function , but I am not sure If usingincluder
is a good way to go. (gonna need a test for this I guess :( )https://www.npmjs.com/package/ejs
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Version
I guess it is all version :/
Additional context Add any other context about the problem here.