Why is > sometimes red

View: New views
3 Messages — Rating Filter:   Alert me  

Why is > sometimes red

by Chris Kutler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Most times in an erb file, when I click on a <%, <%=  or  %>, it and its mate are highlighted in yellow. Sometimes, when I click to the right of an ending %>, the > is highlighted in red and the beginning < is not highlighed. Do you know why?

In the following code,  the first and third are highlighted correctly, but I get red on the > for the 2nd line.


<% @post_comments.each do |comment| %>
  <%= render :partial=>"comment", :object => comment %>  << red
<% end %>


In the following code, I get red for the first line but not the others

<% form_remote_tag :url => {:action => 'post_comment'} do %>   << red
   <p><label for="comment_comment">Comment</label><br/>
   <%= text_area 'comment', 'comment' %></p>

   <%= submit_tag "Post" %>
<%end %>

Re: Why is > sometimes red

by bruparel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Chris,
I am working with NetBeans HTML editor.  I can tell you that I have observed similar puzzling behavior in the pure HTML files as well.  Thing is:  it is temporary.  So for example if I open an HTML document, the <HTML> opening tag can get high-lighted in Red instead of Yellow sometimes, but that goes away once the file is fullly loaded and you move the cursor around.  If you come back to the same HTML tag, it will be high-lighed in green now.  I suspect that the HTML editor is trying to fully parse the document and haven't caught up therefore the tag arbitrarily gets high-lighted in Red.
I am not sure if that is what you are observing in the ERB editor?
Bharat

Re: Why is > sometimes red

by Daniel Bye-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Apr 25, 2008 at 06:06:59AM -0700, Chris Kutler wrote:

> Hi,
>
> Most times in an erb file, when I click on a <%, <%=  or  %>, it and its mate
> are highlighted in yellow. Sometimes, when I click to the right of an ending
> %>, the > is highlighted in red and the beginning < is not highlighed. Do you
> know why?
>
> In the following code,  the first and third are highlighted correctly, but I
> get red on the > for the 2nd line.
>
>
>
> <% @post_comments.each do |comment| %>
>   <%= render :partial=>"comment", :object => comment %>  << red
> <% end %>
>
>
>
> In the following code, I get red for the first line but not the others
>
> <% form_remote_tag :url => {:action => 'post_comment'} do %    << red
>    <p><label for="comment_comment">Comment</label><br/>
>    <%= text_area 'comment', 'comment' %></p>
>
>    <%= submit_tag "Post" %>
> <%end %>
I've noticed this, too. It seems to be down to the fact the parser seems
to not group <% and %> as a pair - instead, it just observes the < >, so
that in hash assignments, the > of the => is taken as the closing token
for the erb tag <%.

So in your example, above, the <%= is matched (in the opinion of the
parser, at any rate) by the first => in your hash assignments. In the
correctly highlighted cases, there are no other angle brackets embedded
between your erb tags.

I don't know if this has been logged as a bug? I haven't time to check
right now, I'm late for work already! ;-)

Dan

--
Daniel Bye
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \


attachment0 (202 bytes) Download Attachment