Hi, I wonder which is better between [1] and [2]. [1] ------layouts/application.html.erb-------- ... <div id="content"> <%= yield %> </div> ... -------some_action.html.erb-------- ... <h1>Page title</h1> <p>Some contents...</p> ... [2] ------layouts/application.html.erb-------- ... <%= yield %> ... -------some_action.html.erb-------- <div id="content"> ... <h1>Page title</h1> <p>Some contents...</p> ... </div> 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I prefer [1] as it''s less painful to write the views. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sam,> Hi, > > I wonder which is better between [1] and [2]. > > [1] > ------layouts/application. > html.erb-------- > ... > <div id="content"> > <%= yield %> > </div> > ... > > -------some_action.html.erb-------- > ... > <h1>Page title</h1> > <p>Some contents...</p> > ... > > [2] > ------layouts/application.html.erb-------- > ... > <%= yield %> > ... > > -------some_action.html.erb-------- > <div id="content"> > ... > <h1>Page title</h1> > <p>Some contents...</p> > ... > </div> >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: http://www.facebook.com/edceekays | 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 Perez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> a écrit :> I prefer [1] as it''s less painful to write the views. > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 Kachale <edmond.kachale-qPoFbzSWEfuuL8s4vL5bMA@public.gmane.org>> Sam, > > Hi, >> >> I wonder which is better between [1] and [2]. >> >> [1] >> ------layouts/application. >> html.erb-------- >> ... >> <div id="content"> >> <%= yield %> >> </div> >> ... >> >> -------some_action.html.erb-------- >> ... >> <h1>Page title</h1> >> <p>Some contents...</p> >> ... >> >> [2] >> ------layouts/application.html.erb-------- >> ... >> <%= yield %> >> ... >> >> -------some_action.html.erb-------- >> <div id="content"> >> ... >> <h1>Page title</h1> >> <p>Some contents...</p> >> ... >> </div> >> > > > 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: http://www.facebook.com/edceekays | 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 Perez <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> a > écrit : > > I prefer [1] as it''s less painful to write the views. >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sam Kong wrote:> Hi, > > I wonder which is better between [1] and [2]. > > [1] > ------layouts/application.html.erb-------- > ... > <div id="content"> > <%= yield %> > </div> > ... > > -------some_action.html.erb-------- > ... > <h1>Page title</h1> > <p>Some contents...</p> > ... > > [2] > ------layouts/application.html.erb-------- > ... > <%= yield %> > ... > > -------some_action.html.erb-------- > <div id="content"> > ... > <h1>Page title</h1> > <p>Some contents...</p> > ... > </div> > > > 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? > > SamBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.