pugjs/pug

Order of attributes matters when it includes a special character

Open

#2,967 建立於 2018年3月1日

在 GitHub 查看
 (8 留言) (0 反應) (0 負責人)JavaScript (21,509 star) (1,955 fork)batch import
Good First Issue

描述

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)

貢獻者指南

Order of attributes matters when it includes a special character · pugjs/pug#2967 | Good First Issue