Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.6.x] Fix whitespaces after else{...} and elseif{...} is not shown #712

Merged

Conversation

yousuketto
Copy link
Contributor

The parser does not recognize whitespace after else {...} as a plain, so it is not showing.

Refs #711

Copy link
Member

@mkurz mkurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, however I think the last whitespaceNoBreak? has to be removed now from

* elseCall : whitespaceNoBreak? "else" expressionPart whitespaceNoBreak?

or not?

Or actually... isn't following correct actually?

  *   elseCall : whitespaceNoBreak? "else" whitespaceNoBreak? expressionPart

@yousuketto
Copy link
Contributor Author

Oh, I didn't notice the document. As you say, it has to be changed as the following. Thanks.

  *   elseCall : whitespaceNoBreak? "else" whitespaceNoBreak? expressionPart

@yousuketto
Copy link
Contributor Author

Furthermore, I noticed that elseIfCall has the same bug as elseCall. I'll fix it too.

@(b: Boolean, b2: Boolean)
x@if(b) {ifbody} <-whitespace
x@if(b) {ifbody} else if(b2) {elseifbody} <-whitespace
scala> com.github.yousuketto.txt.sample(true, false)
val res0: play.twirl.api.TxtFormat.Appendable =
xifbody <-whitespace
xifbody<-whitespace

scala> com.github.yousuketto.txt.sample(false, false)
val res1: play.twirl.api.TxtFormat.Appendable =
x <-whitespace
x<-whitespace

scala> com.github.yousuketto.txt.sample(false, true)
val res2: play.twirl.api.TxtFormat.Appendable =
x <-whitespace
xelseifbody<-whitespace

@yousuketto
Copy link
Contributor Author

I also fixed a bug in elseIfCall. If we need to split this pull request, I'll split it. Please let me know.

@yousuketto yousuketto changed the title Fix whitespaces after else{...} is not showing Fix whitespaces after else{...} is not shown Nov 15, 2023
@yousuketto yousuketto changed the title Fix whitespaces after else{...} is not shown Fix whitespaces after else{...} and elseif{...} is not shown Nov 15, 2023
@mkurz
Copy link
Member

mkurz commented Nov 16, 2023

Perfect, thanks!

@mkurz mkurz merged commit 5bc8944 into playframework:1.6.x Nov 16, 2023
14 checks passed
@mkurz
Copy link
Member

mkurz commented Nov 16, 2023

@Mergifyio backport main

Copy link
Contributor

mergify bot commented Nov 16, 2023

backport main

✅ Backports have been created

mergify bot added a commit that referenced this pull request Nov 16, 2023
[main] Fix whitespaces after `else{...}` and `elseif{...}` is not shown (backport #712) by @yousuketto
@mkurz
Copy link
Member

mkurz commented Nov 16, 2023

Thanks! This is now included in just released twirl 1.6.3 and 2.0.2

@ihostage ihostage changed the title Fix whitespaces after else{...} and elseif{...} is not shown [1.6.x] Fix whitespaces after else{...} and elseif{...} is not shown Nov 16, 2023
@yousuketto
Copy link
Contributor Author

It's so helpful. Thanks for releasing.

@yousuketto yousuketto deleted the fix-whitespaces-after-ifExpression branch November 17, 2023 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants