how to fix: haml_tag outputs directly to the Haml template. Disregard its return value and use the - operator, or use capture_haml to get the value as a String.

219 views
Skip to first unread message

mtin79

unread,
Jul 8, 2009, 6:43:49 PM7/8/09
to Haml
sorry i really don`t know how to fix this as the documentation and
examples are kinda rare. the above error message is shown when the
view tries to render the following:

....................................................................................................................
def render_locationbookmarks(bookmark)
bookmark_actions = []
bookmark_actions << link_to_remote("", :url => { :controller =>
"bookmark", :action => "load_location", :id => bookmark.id }, :html =>
{:class => "action locate"})
bookmark_actions << link_to_remote("", :url => { :controller =>
"bookmark", :action => "delete_location", :id => bookmark.id }, :html
=> {:confirm => "Do you really want to delete this bookmark?", :class
=> "action delete"})


capture_haml do
haml_tag(:h3, {:id => "bookmarkN#{bookmark.id.to_s}", :class =>
"filterName"} ) do
haml_concat bookmark.name
end
haml_tag(:p, { :id => "bookmarkD#{bookmark.id}"}) do
haml_concat bookmark.description
end
haml_tag(:ul) do
bookmark_actions.each do |action|
haml_tag :li, {:class => "action"} do
haml_concat action
end
end
end
end
end
.................................................................................................................................................

i know you guys will kill me first cause i am putting that much
rendering in the helper. but after i am dead i`d really like to know
how this can be refactored via haml in the helper.

thanks,

martin

mtin79

unread,
Jul 8, 2009, 6:52:51 PM7/8/09
to Haml
ok. actually the error was in two lines before the call to last
mentioned helper.

this is the second time i got the wrong line number display where the
error occured. don`t know why this happend.
so the above mentioned code was allright.

but feel free if there are better practices to work with haml in
helpers. or use something completely different?!

Nathan Weizenbaum

unread,
Jul 8, 2009, 8:22:27 PM7/8/09
to ha...@googlegroups.com
Can you supply the template where the error line number was wrong? That's a bug that should be fixed.

mtin79

unread,
Jul 9, 2009, 10:24:04 PM7/9/09
to Haml
hey nathan,
this is the template. error was in line 10 from
render_locationbookmark_icon. but i got line 12 mentionedfrom
render_locationsbookmarks(bookmark):

....................................................................................................
#controlsContent
= error_messages_for :locationbookmark, :object => @locationbookmark

%ul
=# render :partial => "filter/filter_item", :collection =>
@filters
- @locationbookmarks.each do |bookmark|
%li.controlsItem
.icon
= render(:partial => "site/
tab_modal_locationbookmark", :locals => { :bookmark => bookmark })
= render_locationbookmark_icon
.text
= render_locationbookmarks(bookmark)
#controlsFooter
%ul
%li
=# link_to_remote "ALL", :url => { :controller =>
"site", :action => "show_filters", :type =>
FilterHelper::FILTER_TYPE_ALL } \/&nbsp;
%li
= link_to_remote "LOC", :url => { :controller =>
"site", :action => "show_my_locationbookmarks"}
\/&nbsp;
%li
= link_to_remote "USERS", :url => { :controller =>
"site", :action => "show_my_userbookmarks"}
\/&nbsp;
%li
= link_to_remote "EVENTS", :url => { :controller =>
"site", :action => "show_my_eventbookmarks"}
= will_paginate @locationbookmarks, :renderer =>
'RemoteLinkRenderer', :params => {:controller => "site", :action =>
'show_my_locationbookmarks'}

Nathan Weizenbaum

unread,
Jul 10, 2009, 12:54:32 AM7/10/09
to ha...@googlegroups.com
Could you post that to gist.github.com? Gmail is re-formatting the content.
Reply all
Reply to author
Forward
0 new messages