sindresorhus / gulp-template

Render/precompile Lodash templates
MIT License
289 stars 77 forks source link

Cryptic error on template parse error - not enough details provided to properly track down the issue #35

Open arimus opened 8 years ago

arimus commented 8 years ago

I got the following error which was less than simple to track down. I had to comment out blocks at a time in a template that was being parsed in Angular2 until I narrowed it down. It turned out to be that in my template I had:

${{removeContribution.amount}}

instead of

{{removeContribution.amount}}

A typo on my part, however it'd be great to die with a more sensical error that perhaps even pointed out the where. I had to modify the source code to dump the file it was parsing, so I could determine which template it was dying on...then proceed to figure out why.

/Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:487 case 0: return func.call(thisArg); ^ SyntaxError: Unexpected token . at /Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:14776:16 at apply (/Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:487:27) at /Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:15160:16 at apply (/Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:489:27) at /Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:6558:16 at template (/Users/arimus/workspace/project/node_modules/gulp-template/node_modules/lodash/lodash.js:14775:20) at DestroyableTransform._transform (/Users/arimus/workspace/project/node_modules/gulp-template/index.js:21:14) at DestroyableTransform.Transform._read (/Users/arimus/workspace/project/node_modules/readable-stream/lib/_stream_transform.js:159:10) at DestroyableTransform.Readable.read (/Users/arimus/workspace/project/node_modules/readable-stream/lib/_stream_readable.js:357:10) at flow (/Users/arimus/workspace/project/node_modules/readable-stream/lib/_stream_readable.js:727:26)

sindresorhus commented 7 years ago

Pull request welcome :)

Flood commented 7 years ago

Any updates on this?

We are experiencing the same problem using angular-seed here https://github.com/mgechev/angular-seed/issues/1498 and here https://github.com/mgechev/angular-seed/issues/1892

drosi94 commented 7 years ago

Same issue here