mcmath / ejs-html-loader

Webpack loader for rendering HTML from EJS templates
MIT License
47 stars 9 forks source link

nested templates do not recompile #4

Closed WiNloSt closed 8 years ago

WiNloSt commented 8 years ago

I tried using the syntax <% include some/file %> as suggested. Seems only the root and the immediate included templates will recompile when changed. For instance if I have

index.ejs

index.ejs contents
<% include a.ejs %>

a.ejs

a.ejs contents
<% include b.ejs %>

b.ejs

b.ejs contents

And if I require('./index.ejs') somewhere. Only when index.ejs and a.ejs are changed, then webpack will recompile. But when b.ejs is changed, webpack will not recompile.

I also tested including multiple templates in index.ejs, all of those included files including index.ejs will cause webpack to recompile if they changed.

I'm not sure if this is a bug or not. I'm not experience with ejs and webpack that much.

mcmath commented 8 years ago

Interesting. I'll look into it and get back to you shortly.

mcmath commented 8 years ago

It's fixed and released as v2.0.2. Webpack makes it very difficult to test for these kinds of problems, so let me know if you have any other issues. And thanks for your contribution to this project.

WiNloSt commented 8 years ago

Thank you very much. However I'm back to using html-loader because all I wanted from a template engine is just to include other partial template, which I found later that html-loader can do that. Anyway if I have a chance to test this bug I'll let you know.

mcmath commented 8 years ago

Don't go to any trouble to test it; this bug is fixed.

Thanks again.

controversial commented 6 years ago

Doesn't seem to be fixed for me. I'm on ejs-html-loader 3.1.0, webpack 3.8.1, and running into this issue

controversial commented 6 years ago

@WiNloSt I know it was a long time ago that you had this issue, but did you get html-loader to compile nested templates like you describe in this issue? It seems to me that html-loader can't handle nesting at all, and requiring a second partial from a partial throws a ReferenceError: require is not defined.

WiNloSt commented 6 years ago

@controversial Well, I did managed to handle nesting using html-loader at the time. But that was like almost 2 years ago when I was using webpack1. I'm pretty sure things have changed a lot.

The thing is webpack has a bunch of configurations and any of the config or plugins or loaders could have caused the problem.

BTW, if you haven't manage to get this working, and you're happy to share your repository, I would look into solving the problem.