javoire / browserify-ng-html2js

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

problem with path on windows #10

Closed littlemaneuver closed 9 years ago

littlemaneuver commented 9 years ago

Hi,

there is a problem with back slashes in template path on windows when baseDir is set. (That's caused by path.join method).

Porbably you have some ideas how to handle it, thank in advance

javoire commented 9 years ago

Aha,

So you set e.g. baseDir: "path\on\windows" and then this line is run

fileName = opts.baseDir ? file.replace(path.join(appDir, opts.baseDir), '') : file.match(fileMatching)[1];

that joins the baseDir and the appDir. (path.join(appDir, opts.baseDir)).

What's the output of that? Do you get some sort of output in the browser console or terminal?

littlemaneuver commented 9 years ago

The name in template cache is set with back slashes. So file.replace(path.join(appDir, opts.baseDir), '') .replace(/\\/g, '/') works fine for me

javoire commented 9 years ago

Are you using backslashes for baseDir?

littlemaneuver commented 9 years ago

nope, path module takes care of it. The problem is that it returns windows-like path instead of unix-like. so /src/app/some-directive.html doesn't match \src\app\some-directive.html

javoire commented 9 years ago

Ahh I see, the template cache needs to have unix-like paths /src/app/some-directive.html but instead it's given \src\app\some-directive.html (due to the path.join operation) which won't work for angulars template cache?

So file.replace(path.join(appDir, opts.baseDir), '') .replace(/\\/g, '/') fixes that I see. Would you like to do a PR for that?

littlemaneuver commented 9 years ago

heh, of course :)

javoire commented 9 years ago

12