You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 1| each string in ["foo of bar"]
----------------------------------^
2| h1= string
Syntax Error: Unterminated string constant
at makeError (...\app\node_modules\pug-error\index.js:34:13)
at Lexer.error (...\app\node_modules\pug-lexer\index.js:62:15)
at Lexer.assertExpression (...\app\node_modules\pug-lexer\index.js:96:12)
at Lexer.eachOf (...\app\node_modules\pug-lexer\index.js:1090:12)
at Lexer.callLexerFunction (...\app\node_modules\pug-lexer\index.js:1642:23)
at Lexer.advance (...\app\node_modules\pug-lexer\index.js:1671:12)
at Lexer.callLexerFunction (...\app\node_modules\pug-lexer\index.js:1642:23)
at Lexer.getTokens (...\app\node_modules\pug-lexer\index.js:1701:12)
at lex (...\app\node_modules\pug-lexer\index.js:12:42)
at Object.lex (...\app\node_modules\pug\lib\index.js:104:9)
Temporary fix
Assigning the array or object to a variable fixes the problem. For example:
- var testVar = ["foo of bar"]each string in testVar
h1= string
Also, don't start your variable name with "of", as mentioned here: #3263
The error is caused when the word "of" is in a string that's being passed to an each statement. The string can be in an array as show above, or it can be in an object; both cause the error.
The word "of" must also be after any other character (including whitespace) in the string for the error to occur. For example, passing ["of bar"] instead of ["foo of bar"] will not result in an error.
Passing another string after the "foo of bar" string yields a Syntax Error: Unexpected token rather than a Syntax Error: Unterminated string constant as seen here:
> 1| each string in ["foo of bar", "something else"]
--------------------------------^
2| h1=string
Syntax Error: Unexpected token
The rest of the error traceback is identical, so I won't clutter the post by adding it.
The text was updated successfully, but these errors were encountered:
WallTack
changed the title
Passing "foo of bar" to each causing a syntax error
Passing ["foo of bar"] to each causing a syntax error
Jul 4, 2020
error418
added a commit
to error418/pug
that referenced
this issue
Jul 9, 2020
Pug Version:
3.0.0
Node Version:
12.18.0
Input Pug
Expected HTML
Actual HTML
None.
Syntax Error: Unterminated string constant
Full Error
Temporary fix
Assigning the array or object to a variable fixes the problem. For example:
Also, don't start your variable name with "of", as mentioned here: #3263
Additional Comments
Seems related to #3263 (the word "of")
The error is caused when the word "of" is in a string that's being passed to an each statement. The string can be in an array as show above, or it can be in an object; both cause the error.
The word "of" must also be after any other character (including whitespace) in the string for the error to occur. For example, passing
["of bar"]
instead of["foo of bar"]
will not result in an error.Passing another string after the
"foo of bar"
string yields aSyntax Error: Unexpected token
rather than aSyntax Error: Unterminated string constant
as seen here:The rest of the error traceback is identical, so I won't clutter the post by adding it.
The text was updated successfully, but these errors were encountered: