Hi. I''ve just started using MasterView and I''m still groping around through what docs there are. I really dig it, but assorted little things are tripping me up as I get better acquainted with it. I have some questions. The first is, is there a good way to search the mailing list archives? That may help keep me from asking questions that have already been answered. (Also, is there a way to read the list archives without having to use the rubyforge page?) My second question has to do with populating layouts that use multiple yield sections: I have some rhtml templates that used a general layout file that has a section that looks like this: # in layouts/default.rhtml <div class="yui-u first" id="main"> <%= yield %> </div> <div class="yui-u" id="sidebar"> <%= yield :sidebar %> </div> Each page view then has its main layout content, plus a :sidebar section, somewhat like this: # default/somepage.rhtml <h2>The layout header</h2> <div>Some main section stuff</div> <%content_for :sidebar do%> <div><h3>Learn more ...</h3> <p>Learn more about Foo ...</p> <p>Learn more about Bar ...</p> </div> <%end%> I cannot figure out how to do this in MasterView. I keep getting almost, but not quite, results. What sort of works is this in MasterView <div class="main" mv:generate="default/help.rhtml"> <!-- layout --> <h2>The layout header</h2> <div>Some main section stuff</div> <!-- layout end --> <!-- sidebar --> {{{content_for :sidebar do}}} <div><h3>Learn more ...</h3> <p>Learn more about Foo ...</p> <p>Learn more about Bar ...</p> </div> {{{end}}} <!-- sidebar end--> </div> I can only get both the main view content and the sidebar content written out to the generated template if they are wrapped in a common mv:generate section. But in actual use, there is layout markup between them; the resulting MasterView html ends up with them in the wrong place, not within their corresponding mv:replace markup. Hopefuly I''ve manage to explain what I''m trying to so and what results I''m getting. Thanks, James Britt
On 5/18/07, James Britt <james.britt at gmail.com> wrote:> > Hi. > > I''ve just started using MasterView and I''m still groping around through > what docs there are. I really dig it, but assorted little things are > tripping me up as I get better acquainted with it.That''s wonderful! We''re glad to hear it. I have some questions. The first is, is there a good way to search the> mailing list archives? That may help keep me from asking questions that > have already been answered. (Also, is there a way to read the list > archives without having to use the rubyforge page?)I think we do need to summarize some FAQ''s in our documentation to make that easier. I think that Rubyforge used to have a search for the archives, however my connection right now here at the hotel from RailsConf is too slow for me to investigate tonight. I''ll have to answer that question tomorrow after I take a look at what is currently up there now. My second question has to do with populating layouts that use multiple> yield sections: > > I have some rhtml templates that used a general layout file that has a > section that looks like this: > > # in layouts/default.rhtml > <div class="yui-u first" id="main"> > <%= yield %> > </div> > <div class="yui-u" id="sidebar"> > <%= yield :sidebar %> > </div>This should be simply handled by something like <div class="yui-u first" id="main" mv:content="yield"> This can now just be dummy data </div> <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> More dummy content that will be replaced </div> mv:content will replace the contents of the element it occurs on with the <%= attrValue %> Each page view then has its main layout content, plus a :sidebar> section, somewhat like this: > > # default/somepage.rhtml > > <h2>The layout header</h2> > <div>Some main section stuff</div> > > <%content_for :sidebar do%> > <div><h3>Learn more ...</h3> > <p>Learn more about Foo ...</p> > <p>Learn more about Bar ...</p> > </div> > <%end%>This should get you what you want <h2>The layout header</h2> <div>Some main section stuff</div> <div mv:block="conent_for :sidebar do"> <h3>Learn more ...</h3> <p>Learn more about Foo ...</p> <p>Learn more about Bar ...</p> </div> Note that the mv:block will put the necessary ''end'' or closing bracket for you. The code will surround the div that is in. Also something that can be helpful when learning or testing new templates, you can paste snippets into the interactive render page on the MasterView admin pages and see quickly what ERB will be generated. To do this just fire up your local rails project and hit http://localhost:3000/masterview/interact or choose the link off the main http://localhost:3000/masterview page.> > I can only get both the main view content and the sidebar content > written out to the generated template if they are wrapped in a common > mv:generate section. But in actual use, there is layout markup between > them; the resulting MasterView html ends up with them in the wrong > place, not within their corresponding mv:replace markup.Not sure if I got this fully, but just like with normal rails, you can use layouts, and partials to share content across multiple views (everything should work the same way if similar erb is generated. Maybe a code example to illustrate would help me understand what is happening. If you would like to zip something up and attach, I would be glad to take a look. Hopefuly I''ve manage to explain what I''m trying to so and what results> I''m getting.No problem, we know that one of our biggest needs is to improve our documentation, examples, and screencasts. So keep your questions coming and that will help us figure out where we need to focus the efforts. Thanks, Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070519/e86ba3a2/attachment.html
Jeff, thanks for the help. I followed your examples, but now get very peculiar HTML for my page preview after importing the layout and regenerating the pages. Here is an example. The layout (example1.html): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" mv:generate=''layouts/example1.rhtml''> <head><title>Foo</title> </head> <body> <div id="doc2"> <div class="yui-gc"> <div class="yui-u first" id="main"> <div class=''main'' mv:content="yield"> <h4>Welcome to my layout</h4> </div> </div> <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> <p>This should be replaced by the actual sidebar</p> </div> </div> </div> </body> </html> Here is the initial page1.html <html mv:import="layouts/example1.rhtml"> <span mv:generate="example/page1.rhtml"> <h2>The Page 1 Subheader!</h2> <div mv:block="content_for :sidebar do"> <h3>Page 1 sidebar</h3> </div> </span> </html> If I now tell MasterView to update the templates, the rhtml generation is fine, but the new, auto-generated HTML for page1.html ends up with two <html> sections (each one a copy of layouts/example.rhtml), with the original page1 html in the middle: [All of example1.html] [page1.html] [All of example1.html] The odd thing is, this resulting masterview template is not valid XML, as it has mulitple root nodes, but it does not raise any errors. (I''ve attached my HTML layout and page view as a tar file.) Thanks, James -------------- next part -------------- A non-text attachment was scrubbed... Name: mvexample.tar Type: application/x-tar Size: 10240 bytes Desc: not available Url : http://rubyforge.org/pipermail/masterview-users/attachments/20070519/034fbbc6/attachment-0001.tar
On 5/19/07, James Britt <james at neurogami.com> wrote:> > Jeff, thanks for the help. > > > I followed your examples, but now get very peculiar HTML for my page > preview after importing the layout and regenerating the pages. > > Here is an example. > > The layout (example1.html): > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > xml:lang="en" mv:generate=''layouts/example1.rhtml''> > <head><title>Foo</title> </head> > <body> > <div id="doc2"> > <div class="yui-gc"> > <div class="yui-u first" id="main"> > <div class=''main'' mv:content="yield"> > <h4>Welcome to my layout</h4> > </div> > </div> > <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> > <p>This should be replaced by the actual sidebar</p> > </div> > </div> > </div> > </body> > </html> > > > > Here is the initial page1.html > > <html mv:import="layouts/example1.rhtml"> > <span mv:generate="example/page1.rhtml"> > <h2>The Page 1 Subheader!</h2> > <div mv:block="content_for :sidebar do"> > <h3>Page 1 sidebar</h3> > </div> > </span> > </html> > > > If I now tell MasterView to update the templates, the rhtml generation > is fine, but the new, auto-generated HTML for page1.html ends up with > two <html> sections (each one a copy of layouts/example.rhtml), with the > original page1 html in the middle: > > > [All of example1.html] > [page1.html] > [All of example1.html] > > The odd thing is, this resulting masterview template is not valid XML, > as it has mulitple root nodes, but it does not raise any errors. > > (I''ve attached my HTML layout and page view as a tar file.) > > Thanks,Hmm. I''ll take your examples and test to see what is going on. I don''t see anything obvious that is wrong. I should be able to get you a response tomorrow, getting ready to board a plane in a short while. Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070520/a3f442f4/attachment.html
Jeff Barczewski wrote:> ... > Hmm. I''ll take your examples and test to see what is going on. I don''t > see anything obvious that is wrong. I should be able to get you a > response tomorrow, getting ready to board a plane in a short while. >Thanks very much. I''ve been trying different things, and looking to see if perhaps I''ve screwed something up. Basically, though, it seems that the use of "yield :foo" isn''t quite working. James
On 5/21/07, James Britt <james at neurogami.com> wrote:> > Jeff Barczewski wrote: > > > ... > > Hmm. I''ll take your examples and test to see what is going on. I don''t > > see anything obvious that is wrong. I should be able to get you a > > response tomorrow, getting ready to board a plane in a short while. > > > > Thanks very much. I''ve been trying different things, and looking to > see if perhaps I''ve screwed something up. Basically, though, it seems > that the use of "yield :foo" isn''t quite working.Just got back in the office, yesterday was a travel recovery day. That''s what I get for taking the redeye out. Guess I must be getting old, I don''t recover as quickly from being up all night as I used to :-( Anyway, I will look at this today, and determine what the issue is. This should certainly work. Blessings, Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070522/b5960c4b/attachment.html
On 5/22/07, Jeff Barczewski <jeff.barczewski at gmail.com> wrote:> > > > On 5/21/07, James Britt <james at neurogami.com> wrote: > > > > Jeff Barczewski wrote: > > > > > ... > > > Hmm. I''ll take your examples and test to see what is going on. I don''t > > > see anything obvious that is wrong. I should be able to get you a > > > response tomorrow, getting ready to board a plane in a short while. > > > > > > > Thanks very much. I''ve been trying different things, and looking to > > see if perhaps I''ve screwed something up. Basically, though, it seems > > that the use of "yield :foo" isn''t quite working. > >I just realized that I misunderstood the problem. Originally I thought you were referring to the rhtml generation not working properly but actually the issue is within the rebuild template functionality. Sorry about that, I should have read your email slower. I have confirmed the same results you got and now will proceed to find a fix. I''ll also work up a test case so we can be sure it remains fixed. Thanks, Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070523/80f6b805/attachment.html
On 5/19/07, James Britt <james at neurogami.com> wrote:> > > The layout (example1.html): > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > xml:lang="en" mv:generate=''layouts/example1.rhtml''> > <head><title>Foo</title> </head> > <body> > <div id="doc2"> > <div class="yui-gc"> > <div class="yui-u first" id="main"> > <div class=''main'' mv:content="yield"> > <h4>Welcome to my layout</h4> > </div> > </div> > <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> > <p>This should be replaced by the actual sidebar</p> > </div> > </div> > </div> > </body> > </html> > > > > Here is the initial page1.html > > <html mv:import="layouts/example1.rhtml"> > <span mv:generate="example/page1.rhtml"> > <h2>The Page 1 Subheader!</h2> > <div mv:block="content_for :sidebar do"> > <h3>Page 1 sidebar</h3> > </div> > </span> > </html>James, I didn''t catch it earlier, but the simple solution is to add a mv:generate="something" to your layout on or inside your yield. Also for this to work properly we need to use the mv:gen_replace="yield" if we are doing it on the same element as the yield (otherwise the yield would occur in the other file, where as mv:gen_replace makes it happen in the outer file). MasterView was assuming that every template in a rails environment has content to render in addition to potentially generating a layout. So instead of having a file that only generates the layout. If you have it generate the layout and one of the view pages, then everything will work fine. The assumption is based on us wanting to have the minimum number of files, so we expected to make use of every one (to generate a view file in addition to potentially a layout). <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" mv:generate=''layouts/example1.rhtml''> <head><title>Foo</title> </head> <body> <div id="doc2"> <div class="yui-gc"> <div class="yui-u first" id="main"> <div class=''main'' mv:generate="example/page0.rhtml" mv:gen_replace="yield"> <h4>This will be page0 content</h4> </div> </div> <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> <p>This should be replaced by the actual sidebar</p> </div> </div> </div> </body> </html> In the above example I added a mv:generate="example/page0.rhtml" to the same line as the yield. Now when you rebuild it knows by the context/file switch that this is where the view starts. We definitely need to document this better, and if nothing else indicate an error condition when trying to rebuild. Maybe we can clean this up a bit and make it simpler, too. Anyway let me know if this gets you going again. Thanks, Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20070523/25758963/attachment.html
On 5/26/07, James Britt <james at neurogami.com> wrote:> > Using the previous page1.html example, your modified example.html > generates a new page1.html that does not follow the layout of > example1.html. The new page1.html has the fake sidebar div and its > content from example1.html, and places the page1.html sidebar content > alongside the the rest of the page1.html content.James, I believe I understand now. The examples below will create the proper rhtml with a layout and sidebar which will work at runtime, but we are not getting the proper content to work with at design time. PS. There was a bug in the mv:gen_replace="yield" not outputting <%= yield %> it was outputting <% yield %>. Also we were losing the doctype in rebuilds too. These are fixed in 0.3.3 (trunk) which I will attempt to release today. So while we can obtain a running system with layout and sidebar working properly, we are not getting what we expect to design with in the html templates. This is still an issue that I overlooked originally. One work around is to take the sidebar out of the layout and to simply make it part of the view page and then it will work as you would expect. However I will ponder this and see if I can come up with a better solution that allows you to use sidebar or other yields in the layout and also work with these at design time in the other html pages. Sorry it took me a while to understand what you were illustrating. I am going to do a little more testing of 0.3.3 and then release it out so everyone can get the pending fixes, then I''ll see what I can come up with to solve the additional yield design time problem. Here is the example code that will work with 0.3.3 to generate layout with sidebar (but at design time the sidebar content follows the other content rather than putting it where it should be in the view) example.html --------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" mv:generate=''layouts/example1.rhtml''> <head><title>Foo</title> </head> <body> <div id="doc2"> <div class="yui-gc"> <div class="yui-u first" id="main"> <div class=''main'' mv:generate="example/page0.rhtml" mv:gen_replace="yield"> <h4>Welcome to my layout</h4> </div> </div> <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> <p>This should be replaced by the actual sidebar</p> </div> </div> </div> </body> </html> page1.html ------------ <html lang="en" mv:import="layouts/example1.rhtml" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml"> <div mv:generate="example/page1.rhtml"> <h2>The Page 1 Subheader!</h2> <div mv:block="content_for :sidebar do"> <h3>Page 1 sidebar</h3> </div> </div> </html> page1.html (after rebuilding (synchronizing)) ---------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://localhost/TR/xhtml1/DTD/xhtml1-strict.dtd"><html lang="en" mv:import="layouts/example1.rhtml" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml"> <head><title>Foo</title> </head> <body> <div id="doc2"> <div class="yui-gc"> <div class="yui-u first" id="main"> <div mv:generate="example/page1.rhtml"> <h2>The Page 1 Subheader!</h2> <div mv:block="content_for :sidebar do"> <h3>Page 1 sidebar</h3> </div> </div> </div> <div class="yui-u" id="sidebar" mv:content="yield :sidebar"> <p>This should be replaced by the actual sidebar</p> </div> </div> </div> </body> </html> Note that in the rebuilt source, you actually have the sidebar from the layout and you have the content that will be in page1''s sidebar at runtime but it is still in the view. So ideally we would pull this out and put it where it should go for design time. -- 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/20070527/76a673b2/attachment-0001.html