javascriptnode.jsexpresspugjade4j

unexpected text ", in pug file javascript


I'm having the following error. I don't know how to fix it. I new to handling pug files. It is showing the following error:

Error: /home/nobin/jadeApp/views/show_message.pug:9:33
    7|       else
    8|          h3 New person, 
  > 9|             name: #{person.name}, 
---------------------------------------^
    10|             age: #{person.age} and 
    11|             nationality: #{person.nationality} added!

unexpected text ", 
  "
    at makeError (/home/nobin/jadeApp/node_modules/pug-error/index.js:34:13)
    at Lexer.error (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:62:15)
    at Lexer.fail (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:1629:10)
    at Lexer.advance (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:1694:12)
    at Lexer.callLexerFunction (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:1647:23)
    at Lexer.getTokens (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:1706:12)
    at lex (/home/nobin/jadeApp/node_modules/pug-lexer/index.js:12:42)
    at Object.lex (/home/nobin/jadeApp/node_modules/pug/lib/index.js:104:9)
    at Function.loadString [as string] (/home/nobin/jadeApp/node_modules/pug-load/index.js:53:24)
    at compileBody (/home/nobin/jadeApp/node_modules/pug/lib/index.js:82:18)

My show_message.pug file:

html
   head
      title Person
   body
      if(type == "error")
         h3(style = "color:red") #{message}
      else
         h3 New person, 
            name: #{person.name}, 
            age: #{person.age} and 
            nationality: #{person.nationality} added!

Solution

  • Well neither I have any proficiency, but based on your error you might want to try removing the comma at the end of

    .
    .
        name: #{person.name}, 
    

    to

    .
    .
      name: #{person.name}