pugjs/pug

Order of attributes matters when it includes a special character

Open

#2 967 ouverte le 1 mars 2018

Voir sur GitHub
 (8 commentaires) (0 réactions) (0 assignés)JavaScript (1 955 forks)batch import
Good First Issue

Métriques du dépôt

Stars
 (21 509 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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)

Guide contributeur