2

There appears to be a significant table parsing bug in IE9 which my application needs to support. (Internet Explorer 9 not rendering table cells properly & http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/28d78780-c95c-4c35-9695-237ebb912d90/) The issue arises when there is extra whitespace in the table markup.

I'm using Scala style for-each loops in my template to generate the table which is introducing a lot of whitespace to the generated HTML. None of the CSS or HTML meta tags that I've seen are working. One option I haven't tried yet due to the amount of re-work involved is to generate the HTML dynamically with AJAX and clean it up with regex before displaying it. I'm hoping to find a simpler solution. Has anyone else come across this issue and if so, what did you do to fix it?

Community
  • 1
  • 1
catalyst156
  • 143
  • 11
  • see also http://stackoverflow.com/questions/14154671/is-it-possible-to-prettify-scala-templates-using-play-framework-2/14212307 – Adriano Dec 14 '14 at 15:36
  • @AdrienBe Thanks. biesior also noted this other topic and pointed me to it in his answer. – catalyst156 Dec 30 '14 at 16:14

1 Answers1

2

The fastest solution that doesn't require any additional steps is writing condensed code in your view, like:

@for(item <- items){<tr><td>@item.name</td></tr>} 

Optionally you can even write a static method that will trim the value inside very precisely:

@for(item <- items){utils.Trimmer.addTableRow(item.name)}

Using string functions in the class you'll get much better control over spaces and other special chars, than just using bare views.

Finally you can use Google's htmlcompressor to compress and minify whole site, there's is an option remove-intertag-spaces however in this case you'll need to put some hard space to keep the space where required ie, <td>&nbsp;</td>

Take a look at this answer to check how to implement it quite easy in Play 2.x

Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182
  • Thanks for the possible solutions. I finally got around to trying a few things. Unfortunately, simply condensing the code didn't seem to work (not to mention make things quite unmanageable due to nested loops and/or a multitude of custom attributes). I did find that simply moving all the embedded Scala to the leftmost position (shown as the initial attempt at beautifying [here](http://stackoverflow.com/questions/14154671/is-it-possible-to-prettify-scala-templates-using-play-framework-2/14212307#14212307) worked. It's ugly, but it's an initial fix. I'll try html compression soon & report. – catalyst156 Jun 26 '13 at 20:00
  • Sorry for the long delay, but...HTML Compression did the trick! I followed the solution of overriding the Controller methods with a custom class to interface with Google's compressor found in the link you passed along. Many thanks! – catalyst156 Jul 24 '13 at 18:55