Is there a way to prevent comments from being rendered in Rails views?

haml, ruby-on-rails

Solution

There are two different types of comments you can leave in the views:

1) HTML comments which can always be seen by users if they view the source:

<!-- this is a comment -->

2) Ruby comments which will be interpreted as comments on the server and not sent as HTML

HAML:

-# This is a comment

ERB:

<%# This is a comment %>

Problem

I was wondering if there is a way to prevent comments from being rendered in Rails views (other than deleting them). The comments I have in my views are mostly intended for developers and I don't want users to be able to read them in the html. Can I set some rendering option that strips out all of the comments? I am using haml, if that matters.

Original source