In my layout, i have mutiple layouts. Is there any way to reduce to a single line.Currently my layout likes this <%=yield :head%> <%=yield :foot%> <%=yield :bottom%> How to call this in a single method -- 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.
On 12 November 2011 04:38, Nike Mike <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> In my layout, i have mutiple layouts. > Is there any way to reduce to a single line.Currently my layout likes > thisIf you *really* want to (though I don''t know why you would...) <% [:head, :foot, :bottom].each do |to_yield| %><%=yield to_yield %> <%end%> Although strictly, that''s still three lines... How about <%=yield :head%><%=yield :foot%><%=yield :bottom%> ;-)> How to call this in a single methodYou could also move those three lines into a partial, and render that with a single line in your layout. -- 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.
On Nov 12, 2011, at 7:30 AM, Michael Pavling wrote:> On 12 November 2011 04:38, Nike Mike <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> In my layout, i have mutiple layouts. >> Is there any way to reduce to a single line.Currently my layout likes >> this > > If you *really* want to (though I don''t know why you would...) > > <% [:head, :foot, :bottom].each do |to_yield| %><%=yield to_yield %> > <%end%> > > Although strictly, that''s still three lines... > > How about > > <%=yield :head%><%=yield :foot%><%=yield :bottom%> > > ;-)Or just: <%= [ :head, :foot, :bottom ].map {|section| yield section } %> Though it makes be wonder how/why the associated content_for blocks are not together already making this a bit moot. -Rob> >> How to call this in a single method > > You could also move those three lines into a partial, and render that > with a single line in your layout.Rob Biedenharn Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org http://AgileConsultingLLC.com/ rab-/VpnD74mH8+00s0LW7PaslaTQe2KTcn/@public.gmane.org http://GaslightSoftware.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.
On 12 November 2011 16:53, Rob Biedenharn <Rob-GBZH0y1GwQfnZcttdmLDtcI/UQi/AW5J@public.gmane.org> wrote:> Or just: > > <%= [ :head, :foot, :bottom ].map {|section| yield section } %>Yes, of course, that''d work nicely. -- 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.