Sticking an erb block in lambda?


#1

i’m doing some meta stuff and trying to figure out how to stick some
erb html into a proc where i can then feed it to one of many helpers.

if i do something like this:

lamb = lambda do |x|
<%= x %>
end

i get a syntax error because obviously the block isn’t actual code… i
want to be able to do something like <%= html_helper(“something”,
&lamb) %>

any ideas?

thanks!

Stuart


#2

On May 5, 7:02 pm, stewbawka removed_email_address@domain.invalid wrote:

i’m doing some meta stuff and trying to figure out how to stick some
erb html into a proc where i can then feed it to one of many helpers.

if i do something like this:

lamb = lambda do |x|
<%= x %>
end

because you’re in a ruby file, not an erb file you don’t need to be
this complicated:

lamb = lambda do |x|
" #{ x } "
end

It’s a bit more fiddly if you want to call helpers - (one technique is
to have a magic helper object which includes the various rails helpers
so that you can then do magic_helper.number_to_currency … and things
like that)

Fred


#3

nevermind… i’m an idiot… it works you just have to end the %>
before the erb block… duh