Module: BootstrapComponentsHelpers::ModalHelper

Defined in:
lib/bootstrap-components-helpers/modal_helper.rb

Defined Under Namespace

Classes: ModalBuilder

Instance Method Summary collapse

Instance Method Details

Yields:

  • (builder)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bootstrap-components-helpers/modal_helper.rb', line 5

def modal title, options = {}
  builder = ModalBuilder.new self
  yield builder
   :div, class: 'modal fade', tabindex: -1, id: options[:id] do
     :div, class: 'modal-dialog' do
       :div, class: 'modal-content' do
        header =  :div, class: 'modal-header' do
          (:a, '×', class: 'close', data: {dismiss: 'modal'}) + (:h4, title, class: 'modal-title')
        end
        body = (:div, class: 'modal-body') {builder.body_content}
        unless options[:skip_footer]
          footer = (:div, class: 'modal-footer') do
            builder.footer_content || (:a, 'Cancel', class: 'btn pull-right', data: {dismiss: 'modal'})
          end
        end
        header + body + footer
      end
    end
  end
end