James Britt
2007-Aug-14 22:15 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
I have views that use a number of partials. One partial defines the html "head" element, holding common meta elements, css links, and the title element. <html mv:generate="advertiser/new.rhtml"> <head mv:import_render=":partial => ''common/html_header''"> .... I want each page to have a distinct title, so the MasterView HTML has this: <title mv:content="@title">Fake Title</title> However, for this to work I need to assign a value to the @title variable before it is processed. I''m stumped. I can set this in the corresponding action in the controller, but I''d prefer to set it in the view itself so that the designer can set the name. I''ve tried adding a directive right after the html element but before the call to "<head mv:import_render=":partial ... " but MasterView seems to ignore that; it never appears in the resulting rhtml. The MasterView docs do not indicate passing of arguments to mv:import_render; I played around but that does seem to be an option as it would be with a direct rhtml partial reference where you can use a hash to define partial variable values. Suggestions? Thanks, James Britt
Jeff Barczewski
2007-Aug-15 11:08 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
On 8/14/07, James Britt <james.britt at gmail.com> wrote:> > I have views that use a number of partials. > > One partial defines the html "head" element, holding common meta > elements, css links, and the title element. > > <html mv:generate="advertiser/new.rhtml"> > <head mv:import_render=":partial => ''common/html_header''"> > .... > > > I want each page to have a distinct title, so the MasterView HTML has > this: > > > <title mv:content="@title">Fake Title</title> > > However, for this to work I need to assign a value to the @title > variable before it is processed. > > I''m stumped. I can set this in the corresponding action in the > controller, but I''d prefer to set it in the view itself so that the > designer can set the name. > > I''ve tried adding a directive right after the html element but before > the call to "<head mv:import_render=":partial ... " > > but MasterView seems to ignore that; it never appears in the resulting > rhtml. > > The MasterView docs do not indicate passing of arguments to > mv:import_render; I played around but that does seem to be an option as > it would be with a direct rhtml partial reference where you can use a > hash to define partial variable values. > > > > Suggestions?I have typically always defined my titles and page specifc data in my controller, but I can see the benefit of what you are trying to do. I have a couple ideas which might solve the problem. I''ll explore those this morning and let you know my findings. -- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy http://inspiredhorizons.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070815/f4e5a2c8/attachment.html
James Britt
2007-Aug-15 16:09 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
Jeff Barczewski wrote:> > I have typically always defined my titles and page specifc data in my > controller, but I can see the benefit of what you are trying to do. I > have a couple ideas which might solve the problem. I''ll explore those > this morning and let you know my findings.Thanks! James
Jeff Barczewski
2007-Aug-15 20:26 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
On 8/15/07, James Britt <james at neurogami.com> wrote:> > Jeff Barczewski wrote: > > > > > I have typically always defined my titles and page specifc data in my > > controller, but I can see the benefit of what you are trying to do. I > > have a couple ideas which might solve the problem. I''ll explore those > > this morning and let you know my findings. > > Thanks!I worked through a couple ideas and believe that I have a approach that will work. I think it makes sense to be able to modify both the collection, object, and locals that are passed into the partial so that you can change what goes in from any page or even use multiple times on the same page. So the synchronization code will be updated to ignore those types of differences for the gen_partial and import_partial calls and it will keep the existing values when rebuilding. I think this will be a nice change giving much flexibility and it shouldn''t break any existing code since they will have the same values already. I am partially through adding some tests and implementing. Will try to wrap this up by tomorrow if possible and will let you test it out to see if if solves your problems. I''ll shoot you an email when it is ready to roll. Jeff -- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy http://inspiredhorizons.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070815/c5c3001e/attachment.html
James Britt
2007-Aug-17 00:51 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
Jeff Barczewski wrote:> already. > > I am partially through adding some tests and implementing. Will try to > wrap this up by tomorrow if possible and will let you test it out to see > if if solves your problems. > > I''ll shoot you an email when it is ready to roll.Sweet! Thanks, James
Jeff Barczewski
2007-Aug-18 22:04 UTC
[Masterview-users] Placing mv directives as immediate children of the html element
On 8/16/07, James Britt <james at neurogami.com> wrote:> > Jeff Barczewski wrote: > > already. > > > > I am partially through adding some tests and implementing. Will try to > > wrap this up by tomorrow if possible and will let you test it out to see > > if if solves your problems. > > > > I''ll shoot you an email when it is ready to roll.James, Well I finally was able to get the desired functionality with this. If you pull the trunk svn://rubyforge.org/var/svn/masterview/trunk/masterview then it should solve your issue with being able to specify different locals, collections, or objects between each use of gen_partial and import_render. It will also allow you to reuse a partial on the same page with different values. I had to adjust the rebuilding templates system so that it would retain the proper values as well but I like the result. I added some tests to verify operation and it seems to be doing what it should. With this version you should be able to do stuff like <div mv:gen_partial=":partial => ''foo/bar'', :locals => {:title => ''page1''}"> on one template and in another <div mv:import_render=":partial => ''foo/bar'', :locals => {:title => ''page2''}"> or even reuse the template with more import_renders on the same page. Let me know if this fixes things for you and/or causes any other problems. PS. I still need to look into the cruise control issue, will have to get that setup first to look into it. Jeff -- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy http://inspiredhorizons.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070818/652cd025/attachment.html