[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

calling eruby from code?

Xavier Noria

7/6/2003 10:05:00 PM

I've found documentation for running eruby(1) from the command line and
for configuring Apache to handle eruby templates. Do you know how to
process templates from within Ruby code?

Just to be explicit, the idea would be for example to instantiate an
eruby template engine as a Ruby object, pass to it an eruby template as
a string, pass to it in addition a handful of Ruby objects used in the
template, and have the engine process all the stuff and, say, return
the result as a string.

Is that possible? If not, would you recommend some other framework?

fxn
--
s;$;Barcelona Perl Mongers;;$/=$||gaudi||3;map$,+=(split//)*(-1)**$|++,
(split)[.11_09,1.714];$.=$!!~m~erce~;$"=y~catalunya~~,$;=y~rambles~~,$*
=$/^$.;$:=$.+length,$@=$***$**$/**$*%$:,$%=$/*$"-$*;print+chr($_<0xA?$.
."$[$_":m:^$.:?"$.$_":$_)for($**($**$%-$//$/),$%-$*,$,*$/,$***$***$*,$*
**$,,$"*$@+$**$/,$**$,,$;,$***$***$*,$***$*,$.,$**$",$***$,,$***$***$**
$,,$.,$"*$*,$"+$.,$***$,,$,-$.,$"*$@+$**$/,$;*$/**$*,$",$.,++$@+by_fxn)


1 Answer

John W. Long

7/8/2003 3:22:00 AM

0

> I''ve found documentation for running eruby(1) from the command line and
> for configuring Apache to handle eruby templates. Do you know how to
> process templates from within Ruby code?
>
> Just to be explicit, the idea would be for example to instantiate an
> eruby template engine as a Ruby object, pass to it an eruby template as
> a string, pass to it in addition a handful of Ruby objects used in the
> template, and have the engine process all the stuff and, say, return
> the result as a string.
>
> Is that possible? If not, would you recommend some other framework?

Yes it is possible. Take a look at the "apache/eruby-run.rb" file. This ruby
handler for rhtml files demonstrates how to do exactly what you want.
___________________
John Long
www.wiseheartdesign.com