Open Bikeman868 opened 4 years ago
I finally figured out what causes this. The JavaScript functions were copied from my app source and are written using TypeScript. Once I removed the type information the template compiles successfully.
It would be great if the exception thrown by Pug contained something that would at least identify the part of the script that was causing a problem. Thanks.
I encountered the same error today. The reason of that was in this part of pug file:
mixin textField(options)
-
var inputClassName = "text-field__input"
if options.isMasked
inputClassName += " text-field__input_masked"
if options.isForceHoverStyle
inputClassName += " text-field__input_force-focus-hover"
and that error is disappeared after I rewrote conditions to ternary operators:
mixin textField(options)
-
var inputClassName = "text-field__input"
inputClassName += options.isMasked ? " text-field__input_masked" : ""
inputClassName += options.isForceHoverStyle ? " text-field__input_force-focus-hover" : ""
More generally, it seems like this error can be caused by any syntactical error in a multiline code block.
In my case this is cause by a typo const
keyword of JavaScript. In short, this error message needs update for more detail. Too general message could cause dev 'panik'.
This really needs to get fixed. At minimum, it needs a file reference when the problem is in an included pug file instead of only referencing the top most file in the include chain like it does now and a line/column number for the problem.
I'm lost as to why this has never been addressed. This is clearly still open as I've encountered this myself. Am I to expect that closed tickets are really open tickets just brushed under the rug with this package?
I agree with @prodkt as I just encountered it myself.
I'm lost as to why this has never been addressed. This is clearly still open as I've encountered this myself. Am I to expect that closed tickets are really open tickets just brushed under the rug with this package?
The status is "Open" since 2020. The message above is about a referencing Bug in webdiscus / pug-loader which won't be fixed since this is an upstream bug in pug.
Pug version 3.0.0 Node version 12.16.3
Input JavaScript Values
Input Pug
Additional Comments
When the Pug is compiled, it throws an exception "Error parsing body of the with expression". The stack trace provides no useful information for debugging my issue. My template does not contain any "with" expressions.
I tried commenting out various parts of my Pug template to narrow down the issue but was not able to find the part of the template that is triggering this exception.