From: Kirk Haines Date: 2004-07-26T16:06:39+09:00 Subject: Re: rubyonrails and cgikit comparison On Mon, 26 Jul 2004 05:34:03 +0900, Florian Weber wrote > foo > > how would you do this in xml? I'm finding this discussion fascinating as a discussion of different approaches to solving a problem. This particular example intrigued me a bit as while I personally don't like the above sort of mixing of code into HTML, I also found that the CGIKit method of dealing with this that Raphael posted to be more a more roundabout solution that I like, as well. Here's Iowa's take on the above: HTML file: foo Code file: def linkcolor @some_stuff > 3 ? 'red' : 'black' end Now, my approach to this would, if I were planning ahead, would probably be to use a CSS class instead of setting the style directly. That way all I really end up doing is toggling between two different class names, and I let the decision on what effect that has on the link's appearance be determined in the stylesheet. HTML: foo Code: def linkclass @some_stuff > 3 ? 'link_error' : 'link_normal' end CSS: .link_error {color: red} .link_normal {color: black} Either way we are calling a piece of code from the HTML, but the code is not actually embedded in there. If one is working in the designer/developer segregation model, one can either not let the designers write any code at all with this seperation, or if one trusts one's designers to write code like linkclass() themselves, one could structure the code so that while the main code file is the repository for the business logic for the page, and is the domain of the developer, it require's a seperate code file that the designers can use that contains presentation logic that will be used in the template. Something like: class MyPage < Iowa::Component require 'MyPage_layout.rb' # This is the presentation logic file # Everything else is business logic for the page. # . # . # . end Anyway, glad to see your Rails release come to fruition, David. Keep up the good discussions. They are very interesting. Kirk Haines