Skip to main content

Strange Whitespace Management Issue With ColdFusion Custom Tags

By Web Design3 min read

I ran into a strange issue this weekend while working on my CFMailML ColdFusion custom tag DSL (Domain Specific Language). Newline characters, rendered in between two Adobe ColdFusion custom tags, were being stripped out of the page output. To demonstrate, I have a custom tag (noop.cfm) that does nothing except exit out:

Essentially, the start and end modes of this tag are a no-op (No Operation); but, it lets the child content (this.generatedContent) render naturally.

Then I used the cf_noop tag invocation to run four trials:

  1. Three tags, each on a separate line.
  2. Three tags, all on the same line (with spaces).
  3. Three tags, each on a separate line but wrapped in CFOutput.
  4. Three tags, all on the same line (with spaces) but wrapped in CFOutput.

Note that the comments embedded in the following CFML are using HTML syntax. This way, we can see them in the rendered page output for easier reference:

In the rendered output, we would expect that each of the letters, A, B, and C should be separated by a whitespace character. Sometimes it will be the newline, sometimes it will be the space. However, when we run this Adobe ColdFusion 2025 code, we get the following page source:

As you can see, in the first trial — which was three cf_noop tags, each separated by a newline without CFOutput — the output is completely devoid of whitespace. Furthermore, in the third trial, the newlines (wrapped in a CFOuptut) have been replaced by spaces.

Swapping newlines with spaces is less of an issue – unless you’re in a pre tag, whitespace is whitespace. But, stripping out whitespace completely will fundamentally change the visual experience of the rendered page. This is problematic.

Check out the license.


https://bennadel.com/4887


Source link