How can I get more than one partial in a block?

I recently asked a similar question, although this was aimed at the fact that there were several blocks as arguments. This problem is a little more immediate.

I have a problem: I have a helper method that I want to pass to the content as a block for rendering. However, if I add more than one partial, only the last in the block is displayed. The following are the methods.

  def bootrap_panel(title, klass = 'primary', &block)
    content_tag(:div, panel_heading(title) + panel_body(&block), class: 'panel panel-' + klass)
  end

  def panel_body(&block)
    content_tag(:div, yield, class: 'panel-body') if block_given?
  end

And an example of the problem I encountered is here, where only the last part is displayed on the page.

=bootrap_panel 'Panels', 'primary' do
  - render "dynamic_panels/partials/new"
  - render "dynamic_panels/partials/dynamic_panels", dynamic_panels: dynamic_page.dynamic_panels

: , - , ( , ). -, '-' '=' ruby ​​ haml. ?

+4
1

itsef content_tag:

content_tag(:div, class: 'panel-body', &block)

:

content_tag(:div, capture(&block), class: 'panel-body')
+3

Source: https://habr.com/ru/post/1619054/


All Articles