ejs-compiled-loader icon indicating copy to clipboard operation
ejs-compiled-loader copied to clipboard

Upgrade to ejs ^3.0 or dynamic includes

Open SamBroner opened this issue 5 years ago • 2 comments
trafficstars

I'm attempting to upgrade this loader to ejs 3.0 to make dynamic includes easier.

I have a few paths I'm attempting here:

  1. Rebuild this with ejs 3.0. I'm running into an issue with the includes function itself. I believe I'm in the wrong scope for the template function of ejs.

  2. Do dynamic includes using require or some other existing JS infra

I think the issue may ultimately have to do with how webpack-html-plugin is handling templates, but I'd love some guidance.

SamBroner avatar May 22 '20 02:05 SamBroner

After some review, I think require is the easiest way to solve this for me.

However, I did find this caveat on the EJS readme I missed before: https://github.com/mde/ejs#caveats

I need to provide my own fn to do includes here. Seems reasonable.

SamBroner avatar May 23 '20 14:05 SamBroner

You can use include without quotes on your pathname and it seems to work.

<%- include pathname_without_quotes %>

DanielBailey-web avatar Sep 08 '21 02:09 DanielBailey-web