Closed jannisborgers closed 3 months ago
Hi @jannisborgers, thanks for your awesome work (and notes).
There's a couple things that need to be fixed:
node_modules/.bin/prettier --write src/
Running test on my dev environment yield this errors
FAIL tests/Statements/jsfmt.spec.js [ tests/Statements/jsfmt.spec.js ]
FAIL .direnv/flake-inputs/vf031scinzsn9fsxqrxbggnaq13pazll-source/tests/Statements/jsfmt.spec.js [ .direnv/flake-inputs/vf031scinzsn9fsxqrxbggnaq13pazll-source/tests/Statements/jsfmt.spec.js ]
Error: ERROR: Invalid Token
22 | {% macro partner(groupId, value) %}
23 | {# 80 is the groupid of specific hotel websites that may not have a correct partner name #}
> 24 | {{ groupId == 80 ? 'book_hotel_website_test' | translate : value }}
| ^
25 | {% endmacro %}
26 |
27 |
Expected expression end "}}" but found = instead.
❯ TokenStream.error src/melody/melody-parser/TokenStream.js:129:24
❯ TokenStream.expect src/melody/melody-parser/TokenStream.js:103:14
❯ Parser.parse src/melody/melody-parser/Parser.js:162:45
❯ Object.parse src/melody/melody-extension-core/parser/macro.js:54:29
❯ Parser.matchTag src/melody/melody-parser/Parser.js:494:31
❯ Parser.parse src/melody/melody-parser/Parser.js:173:32
❯ Object.parse src/parser.js:82:24
❯ parse4 node_modules/prettier/index.mjs:22117:24
❯ coreFormat node_modules/prettier/index.mjs:22607:7
❯ formatWithCursor node_modules/prettier/index.mjs:22809:14
your patch seems to break comparison operator.
Everything seems to be working as expected. Would like to have some feedback from other people though.
Adds support for arrow functions inside filters, which makes formatting
|filter()
,|map()
and|reduce()
filters possible, resolving #19.Includes a new test file for three scenarios:
I also tested with a variety of other combinations, including named parameters, which all seem to work. I will post my notes in the corresponding issue, in case someone is interested.