Best way to render partial

Hi,

I wonder which is better between [1] and [2].

[1]
------layouts/application.html.erb--------

<%= yield %>
...

-------some_action.html.erb--------

Page title

Some contents...

...

[2]
------layouts/application.html.erb--------

<%= yield %>

-------some_action.html.erb--------

...

Page title

Some contents...

...

Practically they are same.
I think [1] is more DRY.
But I feel kinda weird with [1] because the wrapper div is separated
from the real content.

Which do you think is better?

Sam

I prefer [1] as it’s less painful to write the views.

I prefer using [1] when there are lots of views that shares the same
div#id.
When there is another which changes the style, I only add a wrapper. If
there should be another div, I use a content_for in the views.

Daniel G.
http://survey.richapplabs.com/index.php?sid=62661&lang=en

2010/8/16 Edmond K. [email protected]

Sam K. wrote:

Hi,

I wonder which is better between [1] and [2].

[1]
------layouts/application.html.erb--------

<%= yield %>
...

-------some_action.html.erb--------

Page title

Some contents...

...

[2]
------layouts/application.html.erb--------

<%= yield %>

-------some_action.html.erb--------

...

Page title

Some contents...

...

Practically they are same.
I think [1] is more DRY.
But I feel kinda weird with [1] because the wrapper div is separated
from the real content.

Option 1 is better. The wrapper div, if it’s constant, should be
separated from the content – it’s not a part of the content any more
than a static header or footer would be.

(BTW, I highly recommend Haml instead of ERb.)

Which do you think is better?

Sam

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sam,

...

The second one [2] is ideal in situations where your
layouts/application.html.erb will be used to render different partials
with
varied div ids (for whatever reason). Still you can have a “parent div”
in
your layout template.

Regards,


Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/)
|Malawi

Cell: +265 999 465 137 | +265 881 234 717
Skype: ceekays

Site: http://sites.google.com/site/ceekaysgroup/ | Blog:
http://edceekays.blogspot.com/
Facebook: Redirecting... | Google profile:
http://www.google.com/profiles/kachaleedmond

“A more radical argument for [statistical Natural Language Processing]
is
that human cognition is probabilistic and that language must therefore
be
probabilistic too since it is an integral part of cognition.” – Chris
Manning (1999)
, Foundations of Statistical Natural Language
Processing
.

Le 16 août 2010 15:23:12 UTC+2, Fernando P. [email protected] a
écrit :