Re: "with" statement
by David A. Black other posts by this author
Oct 21 2007 9:39AM messages near this date
Re: "with" statement
|
Re: "with" statement
Hi --
On Mon, 22 Oct 2007, Perry Smith wrote:
> Pascal has a with statement. (I'm showing my age). It would be nice
> instead of:
>
> <td><%= h relationship.parent_id %></td>
> <td><%= h relationship.link_type.pcln %></td>
> <td><%= h relationship.child_id %></td>
> <td><%= h relationship.active %></td>
> <td><%= h relationship.notes %></td>
> <td><%= h relationship.created_at %></td>
> <td><%= h relationship.updated_at %></td>
>
> I could do:
>
> with(relationship) {
> <td><%= h parent_id %></td>
> <td><%= h link_type.pcln %></td>
> <td><%= h child_id %></td>
> <td><%= h active %></td>
> <td><%= h notes %></td>
> <td><%= h created_at %></td>
> <td><%= h updated_at %></td>
> }
You can use instance_eval:
david-a-blacks-computer:~ dblack$ erb
<% a = "hi" %>
<% a.instance_eval do %>
<%= upcase %>
<% end %>
^D
HI
David
--
Upcoming training from Ruby Power and Light, LLC:
* Intro to Ruby on Rails, Edison, NJ, October 23-26
* Advancing with Rails, Edison, NJ, November 6-9
Both taught by David A. Black.
See http://www.rubypal.com for more info!
Thread:
Perry Smith
Dan Yoder
Pete Elmore
Randy Kramer
Giles Bowkett
Robert Klemme
Giles Bowkett
Stefan Rusterholz
Yossef Mendelssohn
Perry Smith
David A. Black
Robert Dober
Stephane Wirtel
|