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

newLine at end of @this(...) and @(...) are not part of content #169

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Feb 20, 2018

This is quite a simple fix and I am wondering why this wasn't addressed yet.

If you have a template that defines a constructor or takes arguments you will always have a newLine in front of your rendered content. People are complaining about this behaviour e.g here and I have seen other comments where people complain about the newLine behaviour of various twirl expressions. This PR fixes a (small) part of that complains.

E.g. given following template:

@(someVar:String)
This is my content

currently renders to the following two lines


This is my content

But actually it should be just one line, without the new line

This is my content

The same happens when you use this(...)

IMHO the newLine at the end of this(...) and @() should not be seens as part of the template. These two lines just define the constructor and the arguments for the render method, but have nothing to do with the content.

Eventually my fix will also remove a lot of newLines for many people because usually you template call other templates that call other templates ... etc. so you will end up with many ugly new lines no one needs or wants.

All my pr does is calling check("\n") after the argument lists which swallows a new line if there is one.

Copy link
Member

@richdougherty richdougherty left a comment

Choose a reason for hiding this comment

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

👍Thanks!

@mkurz
Copy link
Member Author

mkurz commented Feb 21, 2018

@richdougherty So you are ok to merge this? Or want someone else to approve?

@marcospereira
Copy link
Member

Thank you, @mkurz.

@mkurz mkurz deleted the noNewLineAtTop branch February 21, 2018 20:52
@marcospereira
Copy link
Member

marcospereira commented Feb 22, 2018

Backport to 1.3.x: a351758

@mkurz
Copy link
Member Author

mkurz commented Feb 22, 2018

Great, thanks for backporting 😄

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