Skip to main content
Inspiring
February 19, 2010
Question

supressing white space using code

  • February 19, 2010
  • 2 replies
  • 5095 views

We need to supress white space using code, unfortunately the server is shared and we do not have access to the administrator to make the appropriate changes.

I tried placing this at the top

<cfsetting enablecfoutputonly="true">

Then wrapping the HTML output with CFOUTPUT

However when I view the resulting source code I still get 11 line breaks above all of the code.

Is there anything else I can try?

I'm also wondering why <cfsetting enablecfoutputonly="true"> does not function

Thanks

Mark

This topic has been closed for replies.

2 replies

Inspiring
March 8, 2010

(Shrug...)  I just have a standard "header.cfm" include which I use at the start of everything, and it includes <cfoutput reset="yes">.

Does it remove all of the white space?  No.  But it does get rid of a reasonable amount of it, and it's easy to fuhgeddaboudit.

ACS LLCAuthor
Inspiring
March 8, 2010

right now I have this at the top of the CFM (XML) file

<cfprocessingdirective suppresswhitespace="Yes"><cfcontent type="text/xml; charset=utf-8"><?xml version="1.0" ?>

With no space before the <? part

Then at the end


</root></cfprocessingdirective>

It seems to give me what I need because the important part was just making sure that there was no white space at the top, otherwise the XML would not read correctly.

I don't have any CF code parsing inside the file, YET, but I will do, and from what I remember from my tests switching off cfouptut with CFSILENT around all the code seemed to work.

I'm not familiar with the CFOUTPUT RESET="yes" , what does that do? the more tags the better ;-)

Thanks

Mark

Inspiring
February 19, 2010

cfsilent

ACS LLCAuthor
Inspiring
February 19, 2010

Thanks Dan,

I might actually have another solution. I'm creating a file with .CFM extension but it needed to display XML output, which is why I needed to remove the white space.

Looking at the documentation it looks like I needed a CFCONTENT

<cfprocessingdirective suppresswhitespace="Yes">

<cfcontent type="text/xml; charset=utf-16">

It appears to view correctly in a browser although the source code has some weird characters in it when you view source, although the white space appears to disappear now.

The only thing that gets me now is whether I need to use CFXML, I tried the example and it worked, but when I tried it myself I could not get it working right.

Any idea if CFXML a must? It looks like with CFCONTENT I have what I need

Thanks

Mark

ACS LLCAuthor
Inspiring
February 19, 2010

It appears that I need a combination of commands to totally elimitate the unwanted white space.

Perhaps this is because it's different types of white space? Some of it was generated when I did not have cold fusion code at the top of the page, but when I added some CF code, a bogus CFIF command, it created more space which the suppresswhite space did not seem to remove

So it looks like I had supresswhitespace removing white space that came from nowhere, the 11 blank line breaks at the top, and then the CFsilent was knocking out white space created by the bogus CFIF code.

However, I also had to add a CFCONTENT which is fine because it is an XML

<cfprocessingdirective suppresswhitespace="Yes">

<cfcontent type="text/xml; charset=utf-8">

<cfsilent>

bogus CFIF command in here to test

</cfsilent>

XML output here

</cfprocessingdirective>

I'm guessing that if I wanted to output HTML without all this white space, which would cause me to drop the CFCONTENT that it just would not work... weird.

Mark