« Return to Thread: RHTML comments

Re: RHTML comments

by Tor Norbye :: Rate this Message:

Reply to Author | View in Thread

On Aug 2, 2007, at 2:10 PM, James Moore wrote:

> Given:
>
> <%
> a = :snark
> b = 2
> %>
>
> I'd expect the result to be:
>
> <%
> # a = :snark
> # b = 2
> %>
>
> For a one-liner (or N consecutive one-liners), it'd be what's been
> mentioned before:
>
> <% a = :snark %>
> <% b = 2 %>
>
> <%# a = :snark %>
> <%# b = 2 %>
>
> The if-false block seems like a different operation than "comment  
> this region."

Just to tie up this thread - thank you all for your feedback.  I  
implemented something similar to the below:

Toggle comment for

    <% foo %>

will create

    <%# foo %>

(and toggle again gives you back what you had.)

For non-Ruby lines in the RHTML file, like this:

    <p>
    Hello World
    </p>

I also use RHTML-style comments such that the lines will be removed  
from output:

    <%#*<p>%>
    <%#*Hello World%>
    <%#*</p>%>

Toggling again will bring back what you originally had - <p>Hello  
World</p>.

The reason I stick an extra "*" in there is such that I can correctly  
uncomment/comment the code. Otherwise, how can I uncomment the below?

      <%# foo %>

Is it Ruby code, which should uncomment to
      <% foo %>
or is it text, which should uncomment to
     foo
?
The * is what gives it away.

Hopefully this works well enough for 6.0. File any bugs or  
suggestions for improvements with the issue tracker.

-- Tor




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

 « Return to Thread: RHTML comments