Greetings, I''m a newby to both "R"s in RoR. I would like to use Builder::XmlMarkup to generate my pages. If there is a working downloadable example somewhere, that would probably be enough. Otherwise, here''s what I want to do: With the following controller: class AccountsController < ApplicationController layout ''accounts'' model :account def edit @edit_p = "place holder example para" end end I want to understand how to convert the scaffold generated layout: <html> <head> <title>: <%= controller.action_name %></title> <%= stylesheet_link_tag ''scaffold'' %> </head> <body> <%= @content_for_layout %> </body> </html> and template: <h1>Editing accounts</h1> <%= start_form_tag :action => ''update'', :id => @accounts %> <%= render_partial "form" %> <%= submit_tag "Edit" %> <%= end_form_tag %> <%= link_to ''Show'', :action => ''show'', :id => @accounts %> | <%= link_to ''Back'', :action => ''list'' %> to .rxml using Builder::XmlMarkup... something like acccounts.rxml: xml.html { xml.head { xml.title { controller.action_name } stylesheet_link_tag ''scaffold'' } xml.body { @content_for_layout } } and convert the template to edit.rxml that at least starts off doing this: error_messages_for ''accounts'' xml.p(@edit_p) Any help appreciated. Best, Russell
Demetrius Nunes
2005-May-01 00:45 UTC
Re: Example using Builder::XmlMarkup and .rxml files?
You can take a look at the eXPlain project. All templates are built using XmlMarkup: http://rubyforge.org/projects/explainpmt/ rgds Dema Russell L. Carter wrote:> Greetings, > I''m a newby to both "R"s in RoR. I would like to use Builder::XmlMarkup > to generate my pages. If there is a working downloadable example > somewhere, that would probably be enough. Otherwise, here''s what > I want to do: > > With the following controller: > > class AccountsController < ApplicationController > layout ''accounts'' > model :account > def edit > @edit_p = "place holder example para" end > end > > I want to understand how to convert the scaffold generated layout: > > <html> > <head> > <title>: <%= controller.action_name %></title> > <%= stylesheet_link_tag ''scaffold'' %> > </head> > <body> > > <%= @content_for_layout %> > > </body> > </html> > > and template: > > <h1>Editing accounts</h1> > > <%= start_form_tag :action => ''update'', :id => @accounts %> > <%= render_partial "form" %> > <%= submit_tag "Edit" %> > <%= end_form_tag %> > > <%= link_to ''Show'', :action => ''show'', :id => @accounts %> | > <%= link_to ''Back'', :action => ''list'' %> > > to .rxml using Builder::XmlMarkup... something like acccounts.rxml: > > xml.html { > xml.head { > xml.title { > controller.action_name > } > stylesheet_link_tag ''scaffold'' > } > xml.body { > @content_for_layout > } > } > > and convert the template to edit.rxml that at least starts off > doing this: > > error_messages_for ''accounts'' > xml.p(@edit_p) > > Any help appreciated. > > Best, > Russell
Russell L. Carter
2005-May-01 02:35 UTC
Re: Re: Example using Builder::XmlMarkup and .rxml files?
Thank you Demetrius and Erich. Demetrius''s example app looks like it will do. I would not have guessed the syntax, so many thanks. Demetrius, the layout files are still .rhtml, is that for a non-obvious reason? Best, Russell Demetrius Nunes wrote:> You can take a look at the eXPlain project. All templates are built > using XmlMarkup: http://rubyforge.org/projects/explainpmt/ > > rgds > Dema > > Russell L. Carter wrote: > >> Greetings, >> I''m a newby to both "R"s in RoR. I would like to use Builder::XmlMarkup >> to generate my pages. If there is a working downloadable example >> somewhere, that would probably be enough. Otherwise, here''s what >> I want to do: >> >> With the following controller: >> >> class AccountsController < ApplicationController >> layout ''accounts'' >> model :account >> def edit >> @edit_p = "place holder example para" end >> end >> >> I want to understand how to convert the scaffold generated layout: >> >> <html> >> <head> >> <title>: <%= controller.action_name %></title> >> <%= stylesheet_link_tag ''scaffold'' %> >> </head> >> <body> >> >> <%= @content_for_layout %> >> >> </body> >> </html> >> >> and template: >> >> <h1>Editing accounts</h1> >> >> <%= start_form_tag :action => ''update'', :id => @accounts %> >> <%= render_partial "form" %> >> <%= submit_tag "Edit" %> >> <%= end_form_tag %> >> >> <%= link_to ''Show'', :action => ''show'', :id => @accounts %> | >> <%= link_to ''Back'', :action => ''list'' %> >> >> to .rxml using Builder::XmlMarkup... something like acccounts.rxml: >> >> xml.html { >> xml.head { >> xml.title { >> controller.action_name >> } >> stylesheet_link_tag ''scaffold'' >> } >> xml.body { >> @content_for_layout >> } >> } >> >> and convert the template to edit.rxml that at least starts off >> doing this: >> >> error_messages_for ''accounts'' >> xml.p(@edit_p) >> >> Any help appreciated. >> >> Best, >> Russell > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
John Wilger
2005-May-01 04:00 UTC
Re: Re: Example using Builder::XmlMarkup and .rxml files?
On 4/30/05, Russell L. Carter <rcarter-Pifbz6FK28odnm+yROfE0A@public.gmane.org> wrote:> guessed the syntax, so many thanks. Demetrius, the layout > files are still .rhtml, is that for a non-obvious reason?Since I''m the one who wrote eXPlainPMT, I guess I should field the answer to that... ;-) The layout files are in plain html only because that felt easier to work with from a graphic-design standpoint, and they don''t have too much to do with the "programming" side of things. In other words, it was simply a personal choice. As a warning, one thing I noticed during development (although perhaps it has been fixed in more recent versions of Rails) is that using a Builder template caused Rails to send a content type of text/xml rather than text/html (which is technically correct for XHTML), and this can cause rendering problems in some browsers. I did a quick, duct-tape patch to fix this by simply using an "after_filter" to change the content type header across the board. It works, but it ain''t pretty. -- Regards, John Wilger ----------- Alice came to a fork in the road. "Which road do I take?" she asked. "Where do you want to go?" responded the Cheshire cat. "I don''t know," Alice answered. "Then," said the cat, "it doesn''t matter." - Lewis Carrol, Alice in Wonderland
Demetrius Nunes
2005-May-01 20:19 UTC
Re: Example using Builder::XmlMarkup and .rxml files?
John Wilger wrote:> On 4/30/05, Russell L. Carter <rcarter-Pifbz6FK28odnm+yROfE0A@public.gmane.org> wrote: > >>guessed the syntax, so many thanks. Demetrius, the layout >>files are still .rhtml, is that for a non-obvious reason? > > > Since I''m the one who wrote eXPlainPMT, I guess I should field the > answer to that... ;-)And by the way John, let me say that eXPlain is a wonderfully written piece of Rails software and for me it''s kind of a blueprint of how to build apps in Rails and a good learning sample I always indicate for newcomers.
Russell L. Carter
2005-May-01 23:51 UTC
Re: Re: Example using Builder::XmlMarkup and .rxml files?
I just wanted to confirm that Demetrius'' intuition is spot on. I''ve been having "aha!" moments all day reading the eXPlainPMTcode. John Wilger wrote: [...]>As a warning, one thing I noticed during development (although perhaps >it has been fixed in more recent versions of Rails) is that using a >Builder template caused Rails to send a content type of text/xml >rather than text/html (which is technically correct for XHTML), and > >Ok, now I understand this. Thanks for pointing it out. Best regards, Russell>this can cause rendering problems in some browsers. I did a quick, >duct-tape patch to fix this by simply using an "after_filter" to >change the content type header across the board. It works, but it >ain''t pretty. > > >