Partials layouts


#1

In partial I have something like this:

<% if @first == ‘x’ %>
xxx: <%= @data.xxx %>
yyy: <%= @data.yyy %>
<% else %>
yyy: <%= @data.yyy %>
xxx: <%= @data.xxx %>
<% end %>
zzz: <%= @data.zzz %>
qqq: <%= @data.qqq %>

Is there any better way to do this?

I don’t like, that there are same lines 2 times.


#2

On Mar 12, 2009, at 3:59 PM, Fresh M. wrote:

qqq: <%= @data.qqq %>

Is there any better way to do this?

I don’t like, that there are same lines 2 times.

Controller says:
@order = [ ‘xxx’, ‘yyy’ ]

View:
<% @order.each do |a| %>
<%= a %>: <%= @data.send(a) %>
<% end %>
zzz: <%= @data.zzz %>
qqq: <%= @data.qqq %>

Or go all the way and:
@order = [‘xxx’, ‘yyy’, ‘zzz’, ‘qqq’]

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid