J
James Nykiel
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.
## PHP ##
# index.php
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<?php
include("./menu.php");
?>
# menu.php
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<?php
$path = ($_SERVER['SCRIPT_FILENAME']);
$file = basename($path);
if ($file == 'index.php') {
echo 'Home :: ';
}
else {
echo '<a href="index.php" title="Home">Home</a>
:: ';
}
?>
## Ruby / eRuby ##
# index.rhtml
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<%
ERuby.import ('./header.rhtml')
%>
# menu.rhtml
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<%
require 'pathname'
path = Pathname.new(__FILE__).realpath.to_s
file = File.basename path
if file == 'index.rhtml'
puts 'Home :: '
else
puts '<a href="index.rhtml" title="Home">Home</a>
:: '
end
%>
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.
## PHP ##
# index.php
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<?php
include("./menu.php");
?>
# menu.php
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<?php
$path = ($_SERVER['SCRIPT_FILENAME']);
$file = basename($path);
if ($file == 'index.php') {
echo 'Home :: ';
}
else {
echo '<a href="index.php" title="Home">Home</a>
:: ';
}
?>
## Ruby / eRuby ##
# index.rhtml
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<%
ERuby.import ('./header.rhtml')
%>
# menu.rhtml
# Menu item name is non-link if page name is the same as menu item name,
if not then menu item name is link.
<%
require 'pathname'
path = Pathname.new(__FILE__).realpath.to_s
file = File.basename path
if file == 'index.rhtml'
puts 'Home :: '
else
puts '<a href="index.rhtml" title="Home">Home</a>
:: '
end
%>