From: Thomas Fini Hansen Date: 2004-05-29T21:05:11+09:00 Subject: Re: eruby vs php/jsp... On Sat, May 29, 2004 at 08:18:42PM +0900, Andreas Schwarz wrote: > Shannon Fang wrote: > >Hi All, > > > >I am planning a web site for my company that provide e-commerce related > >contents/services. I consider using eruby + mod_ruby. > > I do not think that mod_ruby + eruby is a very good solution (embedding > code in HTML is evil), you should look at a templating system like > kwartz + FastCGI. I don't entirely agree. Yes, having your 'business code' in your HTML is bad juju, but careful with the seperation there. Most interesting 'templating systems' seem to be mini-scripting languages in themselves, because one do need different programming constructs when generating HTML. I was looking around at different templating solutions at one time, because I wasn't particularly happy with anything. Stuff like Smarty for PHP, while being very fancy and powerful, just seemed.. Wrong somehow. It was just rubbing my aesthetics the wrong way. I stumbled across a page where someone was making much the same point, while the idea of having this 'easy language' for your designer seemed like a good idea, it just muddles thing up when you and your designer have to learn this minilanguage, nevermind the time you might spend supporting the more or less well thought out templating system. So why not just use Ruby for the templating? Of course your designer will still have to learn the basics, but you'll save a bit of time. And when he comes with this odd idea, you can just give him a magic-block-of-code to fix his problem, and not waste your time because the templating system doesn't support getting every 3 item of an array, or some sort. Some might say that the same goes for PHP or Perl, but I think Ruby got an edge there in it's marvelously clean syntax. So having thought these thoughts, I was rather happy to se that this was indeed what David is doing in Rails. The templates is just eRuby which get everything it needs handed down from the controller including some convinience methonds, so the most it usually has to do is <% foreach post in @posts %>. So all you got in your templates is presentation logic. Davids done all the hard word for you in Rails, but there's really no reason why you shouldn't be able to use the same principle in mod_ruby + eRuby. -- Thomas beast@system-tnt.dk