Suggestions for commenting/documenting view (.rhtml) files?

I’m writing up my RoR degree project (the project is RoR, not the
degree!), and am unsure of how to document/comment the .rhtml files.
Has anyone else done this before or have any recommendations/suggestion?

Is it best to just do everything in ? This seems
a bit wrong to me for some reason.

<%= this is dislayed on page %>
<% this is pure ruby hidden from page %>

<%# and this is a comment, nothing happens here %>

Shai R. wrote:

<%= this is dislayed on page %>
<% this is pure ruby hidden from page %>

<%# and this is a comment, nothing happens here %>

ah…doesn’t the ruby interpreter have a problem with these lines then?
I thought it would say “unknown method or attribute ‘this’” or
something.

Max W. wrote:

Shai R. wrote:

<%= this is dislayed on page %>
<% this is pure ruby hidden from page %>

<%# and this is a comment, nothing happens here %>

ah…doesn’t the ruby interpreter have a problem with these lines then?
I thought it would say “unknown method or attribute ‘this’” or
something.

just as in a ruby file, the ‘#’ means a comment until the end of the
line.
this will give you an error:

<%# will raise a parsing error
(the opening erb <% and matching closing one arent on the same line
%>

but, you could use comments in erb like so

<%

all of these

are

lines

but the one below me is not

a = 13
%>

<%# this is comment as well %>

<%
=begin
all of the blah blah
here is
one big
multiple line comment, but after the =end
it is plain erb
=end

a = 13
%>

enjoy

On Fri, 14 Sep 2007, Max W. wrote:

[…] and am unsure of how to document/comment the .rhtml files. […]

Is it best to just do everything in ? This seems
a bit wrong to me for some reason.

You can comment the ruby code inside them thusly:

<%

This next method is only used in this file, and doesn’t

belong anywhere else

def do_amazing_magic(spells={})
SufficientlyAdvancedTechnology.execute(spells)
end
%>

    HTH
    Hugh

<%

all of these

are

lines

but the one below me is not

a = 13
%>

this is great - thanks!

Hugh S. wrote:

On Fri, 14 Sep 2007, Max W. wrote:

[…] and am unsure of how to document/comment the .rhtml files. […]

Is it best to just do everything in ? This seems
a bit wrong to me for some reason.

You can comment the ruby code inside them thusly:

<%

This next method is only used in this file, and doesn’t

belong anywhere else

def do_amazing_magic(spells={})
SufficientlyAdvancedTechnology.execute(spells)
end
%>

    HTH
    Hugh

That’s cool, i didn’t realise you could put entire blocks of ruby code
within <% %> - i’d been doing one per line. Thanks!

Hugh S. wrote:

<%

This next method is only used in this file, and doesn’t

belong anywhere else

def do_amazing_magic(spells={})
SufficientlyAdvancedTechnology.execute(spells)
end
%>

Care to share your SufficientlyAdvancedTechnology class? [grin]