Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad escapement #3

Closed
RogueVoo opened this issue Jan 12, 2013 · 4 comments
Closed

Bad escapement #3

RogueVoo opened this issue Jan 12, 2013 · 4 comments

Comments

@RogueVoo
Copy link

JSHint throw error "Bad escapement" when i'm run lint task with Grunt

var id = path.relative(base, file);

https://github.com/ericclemmons/grunt-angular-templates/blob/master/tasks/lib/compiler.js#L17

Variable id contain "backslashes ()" instead "slashes (/)"
I think it's result path.relative in windows environement

@ericclemmons
Copy link
Owner

Thanks for the tip! I'll check it out once I'm back in town. Could you post the full grunt lint output?

Is the issue on the compiled template file, or an issue within the library?

On Saturday, January 12, 2013 at 1:08 PM, RogueVoo wrote:

JSHint throw error "Bad escapement" when i'm run lint task with Grunt
var id = path.relative(base, file);

https://github.com/ericclemmons/grunt-angular-templates/blob/master/tasks/lib/compiler.js#L17
Variable id contain "backslashes ()" instead "slashes (/)"
I think it's result path.relative in windows environement


Reply to this email directly or view it on GitHub (#3).

@RogueVoo RogueVoo reopened this Jan 13, 2013
@RogueVoo
Copy link
Author

Yes, this issue on the library, because she generate invalid templates
Here some lint output:

[L100:C27] Bad escapement.
  $templateCache.put("src\html\item.html",
[L100:C32] Bad escapement.
  $templateCache.put("src\html\item.html",
[L123:C27] Bad escapement.
  $templateCache.put("src\html\list.html",
[L123:C32] Bad escapement.
  $templateCache.put("src\html\list.html",
...

Grunt task config:

ngtemplates:{
    production:{
      options:{
        base:'c:/web/project'
      },
      src: ['src/html/*.html'],
      dest: 'tmp/templates.js'
    }
}

The problem in the function path.relative and the platform where it is called, in my case it windows7 and nodejs 0.8.14

path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
// returns
'..\\..\\impl\\bbb'

Function returns string with double backslashes, and when you put "id" in template they escape and turns to single backslash.

I think AngularJS does not work with backslashes in urls and they must be replaced to slashes "/".
That work fine at L21 in /tasks/lib/compiler.js

  id:  process.platform === 'win32' ? id.replace( /\\/g, '/' ) : id

@ericclemmons
Copy link
Owner

Ah, thank you! I missed the Windows reference.

I'll create a fix for this right away!

Thanks for the issue :)

Eric Clemmons
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Saturday, January 12, 2013 at 9:25 PM, RogueVoo wrote:

Yes, this issue on the library, because she generate invalid templates
Here some lint output:
[L100:C27] Bad escapement. $templateCache.put("src\html\item.html", [L100:C32] Bad escapement. $templateCache.put("src\html\item.html", [L123:C27] Bad escapement. $templateCache.put("src\html\list.html", [L123:C32] Bad escapement. $templateCache.put("src\html\list.html", ...

Grunt task config:
ngtemplates:{ production:{ options:{ base:'c:/web/project' }, src: ['src/html/*.html'], dest: 'tmp/templates.js' } }

The problem in the function path.relative (http://nodejs.org/api/path.html#path_path_relative_from_to) and the platform where it is called, in my case it windows7 and nodejs 0.8.14
path.relative('C:\orandea\test\aaa', 'C:\orandea\impl\bbb') // returns '....\impl\bbb'

Function returns string with double backslashes, and when you put "id" in template (https://github.com/ericclemmons/grunt-angular-templates/blob/master/tasks/lib/compiler.js#L21) they escape and turns to single backslash.
I think AngularJS does not work with backslashes in urls and they must be replaced to slashes "/".
That work fine at L21 in /tasks/lib/compiler.js (https://github.com/ericclemmons/grunt-angular-templates/blob/master/tasks/lib/compiler.js#L21)
id: process.platform === 'win32' ? id.replace( //g, '/' ) : id


Reply to this email directly or view it on GitHub (#3 (comment)).

@ericclemmons
Copy link
Owner

Would you be opposed to simply performing the id.replace across the board (i.e. without the ternary)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants