Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Comments in Templates Render as Blank Lines

timr69563937
Level 2
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
smacdonald2008
Level 10
Level 10

Comments - like those should not be rendered in the HTML

timr69563937
Level 2
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

smacdonald2008
Level 10
Level 10

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

wimsymons
Level 4
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.

timr69563937
Level 2
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.

timr69563937
Level 2
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.

timr69563937
Level 2
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!