This repository has been archived by the owner on Oct 19, 2019. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@ericmorand have created the perfect package to lex Twig code: twig-lexer
When using Twing, we had some issues about whitespace control modifier (
{%-
,{{-
, ...) because they were simply removed from tokens and nodes (see ericmorand/twing/issues/321 and ericmorand/twing/pull/326).But with twig-lexer everything is preserved as tokens, example:
And so it means that we will be able to print those modifiers back :)
Actually I will have to rewrite everything since we will use tokens instead of nodes to prettify Twig code.In fact not everything, but we have to make sure we are using an AST and not only tokens (even with a token stream), otherwise it will be a pain in the ass.Since we won't directly use tokens for an AST, we need to find a way to reserve whitespace control modifiers. That can be weird, but I think we can store (on certain types of node) the opening/closing tags with whitespace modifier controls. 🤔
And also use FastPath instead of our own print function because of (prettier/plugin-php#12):
This PR will close #15, close #4 and close #13