# Partials layouts

**URL:** <https://www.ruby-forum.com/t/partials-layouts/162693>\
**Category:** Rails\
**Created:** [March 12, 2009, 8:59pm UTC](https://www.ruby-forum.com/t/partials-layouts/162693 "2009-03-12T20:59:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 12, 2009, 8:59pm UTC](https://www.ruby-forum.com/t/partials-layouts/162693/1 "2009-03-12T20:59:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [March 12, 2009, 9:21pm UTC](https://www.ruby-forum.com/t/partials-layouts/162693/2 "2009-03-12T21:21:23Z")

</div>

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](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
