Hi,
I have a lot of comments in Rails views.
How i can prevent rendering them ?
Hi,
I have a lot of comments in Rails views.
How i can prevent rendering them ?
There is no easy way to do that. You can monkey patch ERB sources, perhaps, but it is a bit nerdy.
I'm not a Rails programmer, but a quick but of Binging brought up this link: http://blog.brijeshshah.com/strip-tags-in-rails-javascript-and-php/
The approach he's using is one that I've used in the past where you sanitize
the view's output. sanitize
being the name of the function you want to use before rendering the view.
Kind of hackish, but you can wrap it in a helper method
In your view:
<% comment do %>
<%= "this won't be executed" %>
or displayed
<% end %>
in app/helpers/application_helper.rb
module ApplicationHelper
def comment(&block)
## you can do something with the block if you want
end
end
Maybe you can use Haml Comments: -# allow to comment your haml code without them appearing in the generated html.
If I understand the question correctly, you're asking about Ruby/Rails comments vs HTML comments... Give this a try in your view:
<!-- This is an HTML comment and will show up in the HTML source! -->
Now try this:
<%# This is a comment that won't show up in the HTML source! %>
<%#
You can even use this for commenting multiple lines!
How useful!
%>
Does that help?