This is currently a bit of rails code that I have repeated many times in many applications.
<% for @row in @rows -%>
<%= start_form_tag %>
<%= text_field :row, :name %>
<%= hidden_field(:row, :id) %>
<%= end_form_tag %>
<% end -%>
Its a bit much with the <% and %>. It might be worth making a helper for this code in an application, but then again, its probably not. Its hard to read and repetitious.
Therefore, I am proposing the addition of this method in the parser.
def o(input)
_erabout << input + "\n"
end
Which would produce this in the most basic use.
<% o "hello" %>
<%= "hello %> #these two lines are equal
#Taking it a bit further
<% for user in @users
o user.name + "</br>"
#Now, to show how this could really increase code readability... here is a re-write of the code earliest in this post.
<% for @row in @rows
o start_form_tag
o text_field(:row, :name)
o hidden_field(:row, :id)
o end_form_tag
end %>
Now, I am afraid of anyone of the temptation that will come to ex-PHP coders who will want to start doing
<%
o "<img src=''>"
o "<table>"
o myvar
%>
However, I believe this is a feature that, when used properly, could really improve ERb readability. I would not suggest making this a "recommended" way to output information, but just a useful helper for creating excellent looking ERb code.
Thoughts?
-hampton catlin
PS: I know this must seem trivial after the "Oracle Debacle of 2006".
_______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core