-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
[Play 2.3.8] If condition bring line feed in scala template #77
Comments
Is that problem? |
Yup, because of the line breaks and white spaces, the CSS breaks.. There is extra spacing added in between the spaces. |
What do you mean the css breaks? Space between divs should have no impact. Anyway, if you want to remove the whitespace, you can do this:
|
@puneetar could you please send us a comprehensive test case? If you could show us the html with the CSS and explain exactly what is broken, it will be easier to understand what is happening. |
The problem is that it is not easy to use @if conditions without introducing whitespaces, even when it's not intended to append a white space. @Messages("emails.invitedToSharing.sharedTheSpace")
@categoryName(categoryMailData)
@Messages("emails.invitedToSharing.withYou")
@if(categoryMailData.isCommunitySubCategory) {
,<span> @Messages("emails.invitedToSharing.inCommunity")</span>
<span>@categoryName(categoryMailData.inCommunity.get)</span>
} The output is: Expected:
(I don't want a space between "with you" and the ",") I can confirm the solution of @jroper works, but this really makes the HTML much more unreadable and I guess many developers will try to reformat it, creating a bug... @Messages("emails.invitedToSharing.sharedTheSpace")
@categoryName(categoryMailData)
@Messages("emails.invitedToSharing.withYou")@if(categoryMailData.isCommunitySubCategory) {,
<span>@Messages("emails.invitedToSharing.inCommunity")</span>
<span>@categoryName(categoryMailData.inCommunity.get)</span>
} |
@slorber in those situations, you're better off using a helper (either in a Scala file, a Twirl template, or a fragment) that will do the logic for you.
|
yes that could do the job too |
This makes Twirl impractical for plain text templating, say for example when you have both HTML and plain text emails. I quite like having the template separate from my code. I think the approach that Freemarker takes with whitespace stripping and an additional |
Another solution that may work is to allow any whitespace to go between the keyword and the brace. Here is an example of how I want to use Twirl: baseEmail.scala.txt
newAccountEmail.scala.txt
The current workaround: newAccountEmail.scala.txt
If braces could go on the following line it would be a little bit better: newAccountEmail.scala.txt
Ideal solution would be to have some kind of directive that allows the whitespace stripping from lines that only contain tags. At least this would be backwards compatible. Something like: |
Hi all,
I am facing issue with if conditions in scala template. In the following circumstance, the html will have white spaces and line breaks in between the two divs.
The text was updated successfully, but these errors were encountered: