Project

General

Profile

Feature #11624

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

## Problem 

 - ERB is a DSL but commenting out code is not the easy workflow feature in ERB that it is in other languages. 
 - ERB elements were cleverly designed to look like a special kind of html element so it makes programmers unhappy and surprised when commenting the HTML does not affect the ruby elements nested inside. 
 - This makes certain workflows particularly difficult e.g. sketching out a view to aide with iteratively developing its underlying model. 

 ## Solution 

 This proposes a new set of ERB commenting tokens - currently for use with HTML only. 
 They take the form of an HTML comment combined with a Ruby comment.  
 Looks like this: 

 ``` `<#-- 
 <#-- 
 None of this will be outputted: <%= my_ruby_var %> 
 and neither will this 
 --#> 
 ``` --#>` 

 ## Implementation 

 This patch takes a cautious approach. Legacy ERB files may contain typos which happen to match ERB comment token. These are invalid HTML but may have been tolerated and simply printed out in the displayed webpage. For this reason the implementation ignores the ERB comment tokens unless they are properly closed off. This greatly reduces the likelihood of legacy issues and if they do arise they will not disrupt intended functionality. 

 ## Personal note 

 I realise I can't suggest anything that hasn't been thought of already. I see that the main reason this hasn't already been implemented is probably because ERB is not just for HTML. However, it may be that a pair of tokens can be found and proven to be compatible with most languages. 

 Thousands of people clearly continue to want this and the hackiness of the accepted answers on stack overflow shows how others have just gotten used to doing it the hard way. 

 http://stackoverflow.com/questions/3426671/how-does-one-comment-in-an-erb-template 
 http://stackoverflow.com/questions/3127644/block-comments-in-html-erb-templates-in-rails 
 http://stackoverflow.com/questions/3901619/how-to-comment-lines-in-rails-html-erb-files 

 I'd just really like to see this solved even if none of my code is used.

Back