Comments

Haml, Slim, and EGO templates all support comments, but the markers differ by language, and the same / character means opposite things in Haml and Slim. Comments can either be left in the rendered HTML or removed from the rendered HTML.

Haml Comments

In Haml, a rendered HTML comment is created by using the forward slash / character.

%p Now you see me 
/ and now you don't

renders as:

<p>Now you see me</p>
<!-- and now you don't -->

Haml comments that are removed from the rendered HTML entirely are created by using a dash and a pound -# character combination.

%p Now you see me
-# and now you don't

renders as:

<p>Now you see me</p>

These types of comments are stripped out and will not become part of the generated Go code.

Slim Comments

Slim reverses the two Haml markers: / on its own is the silent comment, removed entirely from the rendered HTML, and /! is the one that renders as an HTML comment.

p Now you see me
/ and now you don't
p Now you see me
/! this comment is preserved

renders as:

<p>Now you see me</p>
<p>Now you see me</p>
<!--this comment is preserved-->

If you’re moving between Haml and Slim, remember that Slim’s plain / behaves like Haml’s -#, not like Haml’s plain /.

EGO Comments

EGO comments use <%# ... %> and are removed from the rendered HTML.

<p>Now you see me</p>
<%# and now you don't %>

Nesting

Both kinds of comments can be used to comment out multiple lines of content.

%p Now you see me
/ 
  and now you don't
%p Now you see me
-# 
  %p and now you don't

renders as:

<p>Now you see me</p>
<!-- 
  and now you don't
-->
<p>Now you see me</p>

The examples above are Haml. The same nesting works with Slim’s markers: indent lines under /! to nest them inside a preserved HTML comment, or under / to remove them all silently.

Conditional Comments

Conditional comments are a feature of Internet Explorer in versions prior to IE 10. They are used to include or exclude content from the page based on the version of Internet Explorer that is being used. They are not part of the HTML5 specification and are not supported by GoHT.