Hi all. I’m hoping this is a simple one that someone can put me right
on.
I have a view that ‘wraps’ some div’s around a Page Header and Page
Content, for formatting reasons:
I use this ‘wrapper’ a lot, so I thought I’d put it into a helper,
thus:
def lhs_block(title)
content_tag(:div,
content_tag(:div,
content_tag(:div,title,:class=>‘PageHeader’) +
content_tag(:div,yield,:class=>‘PageContent’),
:class=>‘Page’),
:id=>‘LHS’)
end
This works fine in the view when I do this:
<%= lhs_block(‘Header Here’) {‘Content Here’} %>
Unfortunately, the content is usually more complex that this and multi-
line (as you can imagine), so when I tried to do it this way:
<%= lhs_block(‘Header Here’) do %>
Content Here
<% end %>
All hell broke loose:
compile error
./script/…/config/…/app/views/contacts/index.rhtml:1: parse error,
unexpected ‘)’
_erbout = ‘’; _erbout.concat(( lhs_block(list_filter(‘list_wrapper’))
do ).to_s); _erbout.concat “\n”
^
./script/…/config/…/app/views/contacts/index.rhtml:10: parse error,
unexpected kEND, expecting ‘)’
I thought this was how it was done, but maybe I’m wrong.
If anyone can see anything glaringly obvious that I’ve done wrong,
then any help would be appreciated. Or maybe another way to DRY this
code up so that it’s easier to re-use.
Cheers,
Steve A.