Rob, thanks for doing my homework for me :-)  It looks like
as things are now, we just have to be cognizant of how the content
of our comments might inadvertently prematurely close the
comments.  I still remember in my first ruby app, naively 
using html comments (<!-- blah -->) that sometimes included
snippets of ruby which were dutifully executed, but I didn't
know until I did a "view source" in the browser.  Oops.

        -glenn

Rob Kaufman wrote:
> <%
> =begin this is test code that fails
>    it is on many lines
>    go me
> =end
> %>
> -- works
> 
> <%#
>  this is test code that fails
>    it is on many lines
>    go me
> %>
> --works
> 
> <%
> =begin
> <%= this is test code that fails %>
>    <% it is on many lines %>
>    <%= go me %>
> =end
> %>
> --fail
> 
> <%# <%= this is test code that fails %>
> <%#   <% it is on many lines %>
> <%#   <%= go me %>
> --works
> 
> <%# <%= this is test code that fails %>
> <%#  <div id="site_section">
> <%#   <% it is on many lines %>
> <%# <%= go me %>
> --works (surprise ;-)
> 
>  <%#= this is test code that fails %>
>    <%# it is on many lines %>
>  <%#= go me %>
> --works
> 
> 
> <!--  <%= this is test code that fails %>
>    <% it is on many lines %>
>  <%= go me %> -->
> --fails
> 
> <!--  <-= this is test code that fails %>
>    <- it is on many lines %>
>  <-= go me %> -->
> --works (replace <% with <-)
> 
> <% if false %>
>  <%= this is test code that fails %>
>    <% it is on many lines %>
>  <%= go me %>
> <% end %>
> --works
> 
> 
> Conclusion:  If I was putting in some sort of multiline comment I would use
> <%#
> Stuff you need to know
> now you know it
> %>
> but if I wanted to comment out a chunk of ERB/HTML I would use
> <%# TODO clean up this junk %>
> <%# <%= this is test code that fails %>
> <%#  <div id="site_section">
> <%#   <% it is on many lines %>
> <%# <%= go me %>
> 
> Rob
> 
> On Wed, Jul 2, 2008 at 10:42 PM, Glenn Little <[EMAIL PROTECTED]> wrote:
>> Can't test it now, but I'm pretty sure I already tried
>> the suggested open version (which also is much more
>> artistically appealing, btw) and that it did not like any
>> code within (I think the extra end-ruby "%>" may have
>> confused it).  At least, the IDE didn't like it.  I'll
>> try it in rails 2.1 tomorrow.
>>
>> Is there any other way at all to say unequivocally "do not
>> interpret *anything* between these *here* and *there*?
>>
>> Thanks...
>>
>>        -glenn
>>
>> Rob Kaufman wrote:
>>> Hi Glen,
>>>   Your updated Ruby install means updated ERB.  It is also possible
>>> that the new version of Rails is now prefering Erubis.  Erubis isn't
>>> always 100% the same as the default ERB parser... and there have been
>>> a number of ERB bug fixes and tidies.  The comment syntax you're using
>>> isn't really proper ERB (the syntax, not the library).  If you want to
>>> do a code comment, you should probably leave the <% open.  Does
>>>
>>> <%
>>> =begin
>>> blah blah blah
>>>
>>> =end
>>> %>
>>>
>>> exhibit the same problems?  I agree that tossing a spare <% -%>
>>> doesn't seem right.
>>>
>>> Rob
>>>
>>> On Wed, Jul 2, 2008 at 6:25 PM, Glenn Little <[EMAIL PROTECTED]> wrote:
>>>> I agree to a point, but sometimes the comment is a block
>>>> of exposition explaining usage philosophy or some such.
>>>> I could see a valid argument being made about factoring
>>>> that elsewhere, but frankly sometimes a couple of lines of
>>>> explanation in the middle of code (even view code) is the
>>>> best place when sharing info between you and other programmers
>>>> (or future you).  Another option I suppose would be converting
>>>> them all to the
>>>>
>>>> <%#
>>>> #
>>>> #
>>>> %>
>>>>
>>>> style, as unwieldy as that is.
>>>>
>>>> On the other hand, there are the practical considerations regarding
>>>> all the code that currently has this construct, including our
>>>> in-house code, various plugins we may have used, etc.
>>>>
>>>> I guess I was initially just wondering though if I had missed
>>>> something and inadvertently broken the comment parsing, or
>>>> if what I was seeing was really the way it is now.
>>>>
>>>>        -glenn
>>>>
>>>> Patrick Crowley wrote:
>>>>>> But I'm not yet considering that a valid "fix".  Just a symptom.
>>>>> The easiest fix is to not comment out lots of view code. ;)
>>>>>
>>>>> I generally avoid commenting out view code because it can cause a
>>>>> number of problems (code bloat, exposing templates to users, escaping
>>>>> issues, etc.).
>>>>>
>>>>> I'd move this code into a partial. That way, you can include it when
>>>>> you need it, and remove it when you don't... without hacks.
>>>>>
>>>>> -- Patrick
>>>>>
>>>>>
>>>>>
> 
> > 

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to