T
Tang Hai Tuan Minh
Hi all,
This is my first time into the world of Ruby. I was interested in erb and so
I copied part of a code fragment from the PickAxe book (2nd Ed.) into a
file called sample.html, ran erb over it (erb sample.html), and received
the error message
"(erb): undefined local variable or method `i' for main:Object(NameError)"
The file sample.html is as follows
<html>
<head>
<title> Eruby Example </title>
</head>
<body>
<h1> Enumeration </h1>
<ul>
%5.times do |i|
<li><%=i%></li>
%end
</ul>
</body>
</html>
Now, if I ran erb with erb << ENDRB and write the above code segment before
ENDRB then everything is fine. I had read in the PickAxe book that this is
also similar to what you might get by using irb instead of the ruby
intepreter. However, the solution of sandwiching the code block between
begin and end doesn't help in my case.
Can anyone please enlighten me to a solution ? It's kinda late here so I am
too lazy too think.
TIA,
Minh
This is my first time into the world of Ruby. I was interested in erb and so
I copied part of a code fragment from the PickAxe book (2nd Ed.) into a
file called sample.html, ran erb over it (erb sample.html), and received
the error message
"(erb): undefined local variable or method `i' for main:Object(NameError)"
The file sample.html is as follows
<html>
<head>
<title> Eruby Example </title>
</head>
<body>
<h1> Enumeration </h1>
<ul>
%5.times do |i|
<li><%=i%></li>
%end
</ul>
</body>
</html>
Now, if I ran erb with erb << ENDRB and write the above code segment before
ENDRB then everything is fine. I had read in the PickAxe book that this is
also similar to what you might get by using irb instead of the ruby
intepreter. However, the solution of sandwiching the code block between
begin and end doesn't help in my case.
Can anyone please enlighten me to a solution ? It's kinda late here so I am
too lazy too think.
TIA,
Minh