Unexpected token ) with comments in functions
Auo opened this issue · 2 comments
Auo commented
version: 1.1.2
node: 9.5.0
npm: 5.6.0
os: macOS High Sierra
const dot = require('dot');
const string = `{{
function heyo() {
// this should crash
console.log('hello');
}
}}`;
dot.template(string);
Could not create a template function: var out=''; function heyo() { // this should crash console.log('hello'); } return out;
/Users/aln/Documents/repo/test-dot/node_modules/dot/doT.js:137
throw e;
^
SyntaxError: Unexpected token )
I guess the problem is to know where the comment ends and where the code starts when everything gets on the same line.
Just thought I would share this for future reference.
wagnerpv commented
Yeah, it´s a bit annoying and I think there isn't an easy solution, the workaround that I use is to
/* comment */
like this
epoberezkin commented
Or disable option that strips the white space so the end of line is preserved. But in general, it’s better to use /**/ comments syntax