Nico Ritsche
2007-Oct-29 23:11 UTC
[Masterview-users] conditional styling of html elements
Hi Deb, thanks for your answer! I got this working now: <li mv:attr=":class => #{ controller.controller_name == ''home'' ? ''selected'' : ''not_selected''}"> <a href="../home/index.html" mv:link_to=":controller => ''home'', :action => ''index''">Home</a></li> However, I couldn''t get your other idea working: <li> <a href="../home/index.html" mv:link_to=":controller => ''home'', :action => ''index''">{{{= controller.controller_name == ''home'' ? ''<span class="selected">Home</span>'' : ''Home'' }}}</a></li> This doesn''t compile. Also, if I this was working, the static html would be wrong, as the Link text "Home" would be missing, right? So I would have to include a dummy element. However, I don''t now how to get that working either: I tried to format the "Home" menu option using the selected class in the static html page, just to get an idea of how a selected menu will look like. I tried this: <li mv:attr=":class => #{ controller.controller_name == ''home'' ? ''selected'' : ''not_selected''}"> <a href="../home/index.html" mv:link_to=":controller => ''home'', :action => ''index''"> <span class="selected" mv:replace="">Home</span> </a></li> But it doesn''t compile. My guess is there is a conflict with the mv:link_to directive which just expects a string, not a string with another nested mv directive. Anyway, I''m already quite happy with my current solution, thanks. Something else I noticed: Why does masterview change the formatting of my html? For instance <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22%3E> <html lang="en" mv:import="layouts/admin.rhtml" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml"> becomes <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html <http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd%22%3E%3Chtml>lang="en" mv:import="layouts/admin.rhtml" xml:lang="en" xmlns=" http://www.w3.org/1999/xhtml"> so the linebreak is ignored. I think I saw such more or less sutbtle changes in other places as well. But I can''t remember where right now. I think tabs were ignored. I''d prefer the formatting not beeing touched by masterview. Kind Regards, Nico -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-users/attachments/20071029/ce2dd927/attachment.html
Nico - I''ll follow up on the alt versions of your scenario when I have a chance to set up a test site to play with some of this, but glad to hear you''ve got a workable solution for now for your nav link highlighting (even if not necessarily prettiest/most ideal notation).> > Something else I noticed: > > Why does masterview change the formatting of my html? > [... snip... example of line break changing in DOCTYPE decl...] > > I think I saw such more or less sutbtle changes in other places as well. But > I can''t remember where right now. I think tabs were ignored. > I''d prefer the formatting not beeing touched by masterview. >That turns out to pretty fundamental (and I think fairly typical of this sort of template processing). We necessarily have potentially non-trivial changes in the text between the template and the processed output and masterview makes no attempt to preserve the original formatting. I think that''s a good design decision, it would be difficult to do accurately and in practice I just don''t think it''s a problem worth solving. So the short answer is "tough, deal with it"! The nicer response is that you need to let go of that attachment to your source formatting. (As did I, in fact). The masterview output is a generated artifact, it''s *not* the master source and it''s not the text that you work on when you''re authoring the page, so don''t expect it to be more than it needs to be. It has to be functionally correct and it''s nice if it''s at least reasonably readable, since in practice we *do* end up looking at generated page source at various points in web page development (View Source!), but it doesn''t need to be a precise mirror of the original text. ~ Deb
Jeff Barczewski
2007-Oct-31 21:03 UTC
[Masterview-users] conditional styling of html elements
On 10/31/07, Deb Lewis <djlewis at acm.org> wrote:> > The nicer response is that you need to let go of that attachment to > your source formatting. (As did I, in fact). The masterview output is > a generated artifact, it''s *not* the master source and it''s not the > text that you work on when you''re authoring the page, so don''t expect > it to be more than it needs to be. It has to be functionally correct > and it''s nice if it''s at least reasonably readable, since in practice > we *do* end up looking at generated page source at various points in > web page development (View Source!), but it doesn''t need to be a > precise mirror of the original text. >And I believe that we do keep much of the formatting and things in place when we render but it is possible that in a few places we lose some whitespace in the processing. We took a reasonable effort to keep the original as close as possible without adding too much complexity to the code. I think the majority of the discrepancies might be near the transitions between files. I''ll try to keep your wishes in mind when we are working on some of the modules, if there are opportunities to improve the retention of whitespace. Blessings, 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/20071031/e21831f2/attachment.html