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| <b> <%= x %> </b> 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
On May 5, 7:02 pm, stewbawka <stewba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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| > <b> <%= x %> </b> > endbecause you''re in a ruby file, not an erb file you don''t need to be this complicated: lamb = lambda do |x| " <b> #{ x } </b> " 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> > 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
nevermind.. i''m an idiot.. it works you just have to end the %> before the erb block.. duh On May 5, 3:02 pm, stewbawka <stewba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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| > <b> <%= x %> </b> > 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