Bad escapement
RogueVoo opened this issue · 4 comments
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
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).
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
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)).
Would you be opposed to simply performing the id.replace
across the board (i.e. without the ternary)?