From: John Joyce Date: 2007-07-13T08:09:25+09:00 Subject: Re: Ruby and PHP code in html-page On Jul 12, 2007, at 6:00 PM, Logan Capaldo wrote: > On 7/12/07, John Joyce wrote: >> >> >> On Jul 12, 2007, at 4:50 PM, Jeremy Henty wrote: >> >> > On 2007-07-12, Phrogz wrote: >> >> On Jul 12, 12:43 pm, Jeremy Henty wrote: >> >>> On 2007-07-12, John Joyce >> >>> wrote: >> >>> >> >>>> With php you can just include a file, but ERb doesn't let you do >> >>>> that (AFAIK). >> >>> >> >>> <%= IO.read "yes_it_does.txt" %> >> >> >> >> Not quite when you want the included file to have ERB commands >> in it: >> > >> > Good point! >> > >> > <%= ERB.new(IO.read("how_about_this_then.erb")).result(binding) %> >> > >> > Jeremy Henty >> > >> That's OK I guess, but it's not as graceful as usual Ruby things. >> I guess I'm going to look into Camping and those others. >> I checked out the Merb site once but it was all RDoc with no solid >> examples. > > > You can of course make it more graceful: > > def erb_include(path, b = nil) > b = binding unless b > ERB.new(IO.read(path)).result(b) > end > > > <%= erb_include("file.erb") %> > > It's still a bit icky w/ local vars :( [But that's part of the > reason I > don't like templating like this anyway] > > > CGI is just too ugly, it might as well be Perl for that, I wish >> DreamHost would run mod_ruby... >> I'm just finding that Rails is just way more than what I want or >> need. Lots of cool stuff in it, but the problem is that there is just >> so much there. Getting started is easy enough, but things start to >> grind down to a crawl as you beginning unravelling all the details. >> It's like any big framework, it's highly productive and useful AFTER >> you've spent months learning it. There's definitely a learning curve >> and things start to get pretty complicated pretty quickly. >> >> It's too bad that ERb itself isn't better tutorialized. >> >> Doesn't seem to work with DreamHost's eruby.cgi or with their erb.cgi ... or I'm just an idiot groping in the dark. (mostly likely reason)