hi!
is there some way to make this work:
<% def foo %>
some stuff which should be displayed
<% end %>
..
<%= foo %>
?
First problem: in your example, foo doesn't return a string. It would
try to print "some stuff which..." to whatever output is being used (on
a webserver, the socket). So using <%= tags aren't nessesary.
Second problem: because of the way that output is managed, the scope
inside foo() can't see the output handler. Therefore, you get an error.
Solution:
####### code:
-- define foo
<% foo = lambda do %>
some stuff which should be displayed
<% end %>
-- now, test foo:
<% foo.call %>
-- test foo again:
<% foo[] %>
####### output:
-- define foo
-- now, test foo:
some stuff which should be displayed
-- test foo again:
some stuff which should be displayed
cheers,
Mark