0

I just noticed that when I view my source code in a browser, I have a few thousand blank lines before my actual code begins.

Is this a known issue in Railo? Or is there just a setting I'm missing somewhere?

I'm running Railo 4.0, on Ubuntu

Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
TheJason
  • 494
  • 6
  • 18
  • 1
    Known issue, but not Railo-specific. See http://stackoverflow.com/questions/12021862/remove-whitespace-in-output-html-code/12022086#12022086 for some info. Specifically to prevent content before the doctype declaration, you can reset the buffer with `` - [cfcontent docs](http://railodocs.org/cfcontent). – Peter Boughton Dec 04 '13 at 18:16

2 Answers2

2

In your Railo web administrator, you can turn on "Whitespace Management" in the "Output" settings page (e.g. yoursite.com/railo-context/admin/web.cfm?action=server.output ). It is disabled by default.

You can also use the <cfprocessingdirective suppresswhitespace="true"> setting to turn suppression on and off during the request.

JClausen
  • 321
  • 2
  • 2
  • +1 to this. The "Smart" whitespace compression that Railo offers via the administrators is extremely well done. I have been using it for a while now and it gets rid of those annoying breaks and still leaves the code fairly readable. – Jordan Dec 05 '13 at 00:24
1

The reason for the blank lines is that when you write a CFML template, you are probably putting much of your <CF...> tags (queries and logic) before you write the output/HTML, and each line of code has a CR/LF after it which is rendered in the final output. If you have an Application.cfm (or cfc) file then all that code is also rendering whitespace before your .cfm page as well.

You can use the Whitespace Management feature in the administrator or you can wrap your entire page with a <CFProcessingdirective supresswhitespace="true"> tag, but you can also use the <cfscript> tag, or put your logic inside a <cffunction output="no"...> tag or even a <cfsilent> tag.

Personally, I am big fan of using CFComponent tags (inside a .cfc file) to encapsulate much of the code into "classes" and leave the .cfm files strictly for output rendering.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
Eccountable
  • 622
  • 3
  • 13