hey all, My index.html.haml: - wrap do - page_title "Teams List View" application_helper.rb: def page_title(title) content_tag :h1, title end def wrap(&block) concat(content_tag(:div, capture(&block), :class => "generic_header")) end I load in browser and get: <div class="generic_header"><h1>Teams List View</h1></div> <div class="generic_header"><h1>Teams List View</h1></div> It''s rendered twice. Not sure why. I invoke the wrap iterator, passing a block into the argument list, wrap receivers it as a reference, then I concat a div, use capture to render the page title as nested within div, and assign div class. Not sure what I am doing wrong. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What happens if you get rid of concat()? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
By the way, if you put some html at the top of the page, e.g. %p Index.html.haml - wrap do - page_title "Teams List View" Your wrap() method will double render the whole page. Based on my experiments with haml, I would never consider using a multiline ruby block that contains a rails helper. The results are too unpredictable. Both of these syntaxes do what you want (without concat): - wrap do - page_title "Teams List View" - wrap do = page_title "Teams List View" Note that in this code: content_tag(:div, capture(&block), :class =>"generic_header") ...capture() does indirectly what block.call() does directly. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
thanks for response, and the explanation of capture(). When I removed the concat from the helper, the title stopped rendering twice. I thought the concat was used to concatenate the two blocks of html, but after reading documentation it appears it''s to render haml without using "=". On Sep 5, 8:19 am, 7stud -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> By the way, if you put some html at the top of the page, e.g. > > %p Index.html.haml > - wrap do > - page_title "Teams List View" > > Your wrap() method will double render the whole page. > > Based on my experiments with haml, I would never consider using a > multiline ruby block that contains a rails helper. The results are too > unpredictable. Both of these syntaxes do what you want (without > concat): > > - wrap do > - page_title "Teams List View" > > - wrap do > = page_title "Teams List View" > > Note that in this code: > > content_tag(:div, capture(&block), :class =>"generic_header") > > ...capture() does indirectly what block.call() does directly. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It seems to me that the = sign in haml is arbitrary and capricious. For instance, how does the syntax: - wrap do - page_title "Teams List View" result in anything being added to the page? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.