Hi all i want to use a master template for all my view files to use the rails DRY feature.So How can i achieve that. I already googled it but unfortunately didn''t get much help. any help would be appreciated -- 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.
venkata reddy wrote in post #977331:> Hi all > i want to use a master template for all my view files to use the rails > DRY feature.What do you mean by the rails DRY feature? DRY is coding practice not a framework feature.> So How can i achieve that. I already googled it but > unfortunately didn''t get much help. > any help would be appreciatedYou use layouts for this. You put the common layout ERb (or HAML) in ./app/views/layouts then put the page specific ERb in ./app/views/<whatever> and use <%= yield %> and/or <%= yield :some_content %> inside the layout templates to mark where the page specific code should be rendered. Rails will, by convention, look for ./app/layouts/application.html.erb if no other layout is specified. ./app/layouts/application.html.erb ------------------------------- <!DOCTYPE html> <html> <head> <title>Demo</title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> </head> <body> <%= yield %> </body> </html> ------------------------------- If you haven''t done so already I''d recommend starting right here: http://guides.rubyonrails.org/getting_started.html For information more focused on layouts and views go here: http://guides.rubyonrails.org/layouts_and_rendering.html -- 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.
Marnen Laibow-Koser
2011-Jan-25 20:43 UTC
Re: using master(single) template for all view pages
venkata reddy wrote in post #977331:> Hi all > i want to use a master template for all my view files to use the rails > DRY feature.So How can i achieve that. I already googled it but > unfortunately didn''t get much help. > any help would be appreciatedAre you looking for the use of layouts? http://guides.rubyonrails.org/layouts_and_rendering.html Best, -- 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.
thank u...very good tutorials.. On Jan 26, 1:43 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> venkata reddy wrote in post #977331: > > > Hi all > > i want to use a master template for all my view files to use the rails > > DRY feature.So How can i achieve that. I already googled it but > > unfortunately didn''t get much help. > > any help would be appreciated > > Are you looking for the use of layouts?http://guides.rubyonrails.org/layouts_and_rendering.html > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.