Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Comments in Templates Render as Blank Lines

Avatar

Level 2

We have been trying to eliminate all of the extra blank lines that appear in the markup of our pages, but I have discovered that most of these are actually coming from comments in the template files.

For example....

clientlib-remplate.PNG

Each of those highlighted comments end up as blank lines in the final HTML output. Since each template ends up pulling in more templates, this adds up to a lot of blank lines.

Does anyone know of a way around this? I imagine there isn't, but I thought I should ask.

8 Replies

Avatar

Level 10

Comments - like those should not be rendered in the HTML

Avatar

Level 2

The comments themselves are not rendered, but a blank line is rendered whenever such a comment is encountered in the code. I have verified this by removing the comments in the templates and reloading the resulting page to see the relevant blank lines removed.

I am referring to the extra blank lines that show up in the markup....

blank-line-examples.PNG

Avatar

Level 10

Show the rendered HTML - are you seeing whitespace or blank lines?

Avatar

Level 4

Does the same JSP trick work here? Just remove the newlines from the source.

For example:

<!—

comments here

—><!—

next comment

—><anyhtmltag>

Etc.

If you are delivering content through the dispatcher and it does gzip encoding most of the white space bytes would be removed in the compressed version, so the overhead over the wire would be relatively small.

Avatar

Level 2

Sorry, but I don't think I can share the full HTML. The image I posted shows the head, and you can clearly see all the blank lines. Each blank line there actually corresponds to a comment in a template.

Avatar

Level 2

I did experiment with doing this, but it didn't seem to work. It really is as if the comment itself ends up as a blank line.

Avatar

Level 2

Thanks, Arun. I suppose it could be related, but that depends on whether or not they consider comments the same as other hidden tags. Sure seems like a bug to me and not a new feature!