Re: Need help converting PHP to Ruby / eRuby



On Wed, Apr 30, 2008 at 10:08 PM, James Nykiel wrote:
Hi,

I am new to Ruby / eRuby templating and need some help converting from
PHP, I have two web pages that do what I need using PHP but I can figure
out how to do the same with Ruby / eRuby templating, could someone
please have a look and guide me?

What seems to be happening is that the Ruby / eRuby variable? $file is
being set to menu.rhtml while the PHP variable? $file is being set to
index.php, which is what I want the Ruby / eRuby to do also.

Hi,

try using ENV['SCRIPT_FILENAME'] or $0 instead of __FILE__.

__FILE__ is always the name of *current* file (i.e. the one being parsed).
$0 is the name of the "started" file (the one that was started from outside).
SCRIPT_FILENAME is CGI variable.

Note: not tested, just hints.

Jano

.



Relevant Pages

  • Re: Need help converting PHP to Ruby / eRuby
    ... I am new to Ruby / eRuby templating and need some help converting from ... PHP, I have two web pages that do what I need using PHP but I can figure ...
    (comp.lang.ruby)
  • Re: Need help converting PHP to Ruby / eRuby
    ... I am new to Ruby / eRuby templating and need some help converting from ... PHP, I have two web pages that do what I need using PHP but I can figure ...
    (comp.lang.ruby)
  • Re: RCR to modify #puts and #print inside ERB
    ... >> #2 is much like PHP. ... >> (Ruby code) embedded in self-printing text. ... > In fact, there could only be one language at all, because the people ... >> we shifted the idea from an ERB template to an ERB program? ...
    (comp.lang.ruby)
  • Re: Wordpress Port
    ... I think Ruby is also generally useful. ... easier to work with than Perl. ... PHP was obviously designed ... primarily as a procedural language, so it's sort of appropriate for ...
    (comp.lang.ruby)
  • Language Popularity - PHP vs Ruby?
    ... The trend seems to show that PHP is a very popular ... language compared to ruby. ... Ruby has Rails, but Rails needs more libraries, and Rails has a ...
    (comp.lang.ruby)