pugjs/pug

Order of attributes matters when it includes a special character

Open

#2967 aperta il 1 mar 2018

Vedi su GitHub
 (8 commenti) (0 reazioni) (0 assegnatari)JavaScript (1955 fork)batch import
Good First Issue

Metriche repository

Star
 (21.509 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Pug Version: pug version: 2.0.0-rc.2 pug-cli version: 1.0.0-alpha6

Result is as expected:

Input Pug

doctype html
p({{extra-attributes}} hello="there") hey

Expected and Actual HTML

<!DOCTYPE html><p {{extra-attributes}} hello="there">hey</p>

Problematic case:

Input Pug

doctype html
p(hello="there" {{extra-attributes}}) hey

Expected HTML

<!DOCTYPE html><p hello="there" {{extra-attributes}}>hey</p>

Error:

/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:59
    throw err;
    ^

Error: test.pug:2:17
    1| doctype html
  > 2| p(hello="there" {{extra-attributes}}) hey
-----------------------^
    3| 

Syntax Error: Unexpected token
    at makeError (/usr/lib/node_modules/pug-cli/node_modules/pug-error/index.js:32:13)
    at Lexer.error (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:58:15)
    at Lexer.assertExpression (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:86:12)
    at Lexer.attrs (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1089:18)
    at Lexer.callLexerFunction (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1319:23)
    at Lexer.advance (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1356:15)
    at Lexer.callLexerFunction (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1319:23)
    at Lexer.getTokens (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:1375:12)
    at lex (/usr/lib/node_modules/pug-cli/node_modules/pug-lexer/index.js:12:42)
    at Object.lex (/usr/lib/node_modules/pug-cli/node_modules/pug/lib/index.js:99:27)

Guida contributor