trivago / prettier-plugin-twig-melody

Code formatting plugin for Prettier which can handle Twig/Melody templates
Apache License 2.0
155 stars 35 forks source link

Issues Reading Arrow Functions #70

Closed luisaugusto closed 2 years ago

luisaugusto commented 3 years ago

When I use a filter in a Twig template, such as:

{{ [1,2,3]|filter(x => x == 1) }}

I get the following error:

Error: ERROR: Unexpected token "operator" of value ">"
  20 |
  21 | 
> 22 | {{ [1,2,3]|filter(x => x == 1) }}
     |                      ^
  23 | 
    at TokenStream.error (/node_modules/melody-parser/lib/index.js:1362:22)
    at Parser.error (/node_modules/melody-parser/lib/index.js:830:21)
    at Parser.matchPrimaryExpression (/node_modules/melody-parser/lib/index.js:976:26)
    at Parser.getPrimary (/node_modules/melody-parser/lib/index.js:935:21)
    at Parser.matchExpression (/node_modules/melody-parser/lib/index.js:885:25)
    at Parser.matchArguments (/node_modules/melody-parser/lib/index.js:1244:34)
    at Parser.matchFilterExpression (/node_modules/melody-parser/lib/index.js:1214:29)
    at Parser.matchPostfixExpression (/node_modules/melody-parser/lib/index.js:1139:29)
    at Parser.matchPrimaryExpression (/node_modules/melody-parser/lib/index.js:988:21)
    at Parser.getPrimary (/node_modules/melody-parser/lib/index.js:935:21)

What should happen is that the Twig parsing should recognize an arrow function and be able to format the file correctly.

rubas commented 3 years ago

Bump. Same for map. All arrow functions are not working.

--

@luisaugusto , maybe rename the issue to problems with arrow functions.

rubas commented 3 years ago

Duplicate of #51.