Module: TabsHelper
- Defined in:
- app/helpers/tabs_helper.rb
Instance Method Summary collapse
-
#tab(text = nil, link_url = nil, **opts, &block) ⇒ Array<ActiveSupport::SafeBuffer>
Build a tab and add it to the container generated by #tabs.
-
#tabs { ... } ⇒ ActiveSupport::SafeBuffer
Build a tab container in which to place tabs.
Instance Method Details
#tab(text = nil, link_url = nil, **opts, &block) ⇒ Array<ActiveSupport::SafeBuffer>
Build a tab and add it to the container generated by #tabs.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/tabs_helper.rb', line 23 def tab(text = nil, link_url = nil, **opts, &block) active = opts[:is_active] || false opts.delete :is_active opts[:class] = if opts[:class] "#{opts[:class]} tabs--tab#{active ? ' tab__active' : ''}" else "tabs--tab#{active ? ' tab__active' : ''}" end @building_tabs << if block_given? link_to link_url, **opts, &block else link_to text, link_url, **opts end end |
#tabs { ... } ⇒ ActiveSupport::SafeBuffer
Build a tab container in which to place tabs. Intended for use with a block using #tab.
6 7 8 9 10 11 12 |
# File 'app/helpers/tabs_helper.rb', line 6 def tabs @building_tabs = [] yield tabs = @building_tabs.join("\n") @building_tabs = [] tag.div raw(tabs), class: 'tabs' end |