ColdFusion and Whitespace – Part 2

Continuing on the ColdFusion whitespace hunt, your next weapon is the <cfsilent> tag. This is my personal favourite as it is the most straightforward. You just wrap the cfslient tag around anything and it tells ColdFusion not to output anything to the browser from within it.

... something that has a lot of whitespace in it ...


It also has its own little trap, it does exactly what is said it would – it does not return anything from with in it, so you have to be a little be careful when debugging as you can often get trapped trying to output hints or the contents of variables to your web page and not see it.

Moving onto the cfprocessingdirective tag. This could be the most complicated way of getting whitespace out of our code. Like the cfslient tag, you will need to wrap the code that you want to bring under control

... your code goes here ...


This tells CF to suppress the whitespace characters that are generated by CF. The good news is that if you need to actually include the whitespace you can nest the cfprocessingdirective tags and turn whitespace suppression off again. ( I am still looking for a good reason to do this though)

Next, using java to control the output buffer.

Advertisements