javoire / browserify-ng-html2js

Browserify transform to compile html templates into angular template modules
MIT License
27 stars 17 forks source link

Folder as Part of Module Name #22

Open trisys3 opened 9 years ago

trisys3 commented 9 years ago

Can we do folder name as part of the module name? As it is, this module is pretty much unusable for me, as we have instances of multiple HTML files with the same base name, no matter how much we try to avoid it. This will only increase as we make our app more complex, with multiple npm modules that may all fall under the same base Angular module.

There is probably a way we can avoid this issue, but wouldn't it be better to add the folder name as part of the module name in the first place? You can use things like the path module and __dirname/__filename variables included with Browserify (and we could use them in this transform), that's what they are there for. I don't think they take away too much performance, at least when your app is complex enough to consider using them, but if so I suppose this would be a reason to not implement this feature.

javoire commented 8 years ago

Yeah, I guess this makes sense to have as an option

javoire commented 8 years ago

Hey, I actually started considering that this should be the default behaviour: #38

It is kind of achievable with the baseDir option. Maybe you noticed that. But it could make sense to be default

patrickfabrizius commented 8 years ago

I ran into the same problem and actually started using $templateCache manually with a plain html2js transpiler like so:

myApp.run(function($templateCache) { $templateCache.put('myview.html', require("./views/myview.html")); });

Also, I don't see the upside of creating a module for each template and then DI them in my main module (a lot of DI's ...). But if I'm missing something, please elaborate.

javoire commented 8 years ago

Hey, you can attach all templates to one module using the module option: https://github.com/javoire/browserify-ng-html2js#b-with-gulp