diff --git a/app/helpers/tabs_for/rails/tabs_for_helper.rb b/app/helpers/tabs_for/rails/tabs_for_helper.rb index d313c11..1db04bf 100644 --- a/app/helpers/tabs_for/rails/tabs_for_helper.rb +++ b/app/helpers/tabs_for/rails/tabs_for_helper.rb @@ -2,8 +2,11 @@ module TabsFor module Rails module TabsForHelper - def tabs_for(object, &block) - content_tag(:ul, class: 'nav nav-tabs', role: 'tablist') do + def tabs_for(object, options={}, &block) + classes = 'nav nav-tabs' + classes = options.delete(:class) if options[:class] + + content_tag(:ul, class: classes, role: 'tablist') do capture TabBuilder.new(object, self), &block end + content_tag(:div, class: 'tab-content') do capture PaneBuilder.new(object, self), &block diff --git a/test/tabs_for_helper_test.rb b/test/tabs_for_helper_test.rb index 77c3731..a9826b7 100644 --- a/test/tabs_for_helper_test.rb +++ b/test/tabs_for_helper_test.rb @@ -38,6 +38,15 @@ def assert_pane(id, text) assert_select "div[role=\"tabpanel\"][class=\"tab-pane\"][id=\"#{id}\"]", text: text end + test "custom class for tabs" do + tabs = tabs_for(object, class: 'tab-header') do |b| + b.tab("Label") { "Content" } + end + + concat tabs + assert_select ".tab-header" + end + test "#tab renders tab with translated header with a corresponding pane" do store_translations(:en, activerecord: {attributes: {project: {name: "Nome"}}}) do with_concat_tabs_for(object) { |b| b.tab(:name, size: 1) { "Content" } }