I often find myself adding a trivial comment helper to my nanoc projects to be able to easily comment out sections of a page. I suggest adding it to nanoc as it might be useful to everyone.
Use case: I often have the need to temporarily remove parts of a page. I can't use the Erb comment directive <%# ... %> because that cannot be nested: if the commented section contains a link helper it will break if included inside an Erb comment block. I also don't want to use the HTML comment <!-- ... --> because that leaves the HTML on the page. Ruby doesn't have a "no op" statement like some other languages do, <% if false %> ... <% end %> works but it's not very pretty.
So I find myself adding this trivial helper in default.rb:
def comment(...);end
This allows me to do something like:
<% comment 'This still needs to be translated' do %>
Text here
<% end %>
I often find myself adding a trivial
comment
helper to my nanoc projects to be able to easily comment out sections of a page. I suggest adding it to nanoc as it might be useful to everyone.Use case: I often have the need to temporarily remove parts of a page. I can't use the Erb comment directive
<%# ... %>
because that cannot be nested: if the commented section contains a link helper it will break if included inside an Erb comment block. I also don't want to use the HTML comment<!-- ... -->
because that leaves the HTML on the page. Ruby doesn't have a "no op" statement like some other languages do,<% if false %> ... <% end %>
works but it's not very pretty.So I find myself adding this trivial helper in
default.rb
:This allows me to do something like:
Alternatively, it could be named
skip
ordiscard
.