module Admix class Tab # include ActionView::Helpers::CaptureHelper # include ActionView::Helpers::TagHelper attr_reader :tab_id, :header, :content, :view_context, :options def initialize(view_context, tab_name, tab_id = nil, options={}, &block) @view_context ||= view_context @tab_id = "tab-#{tab_name}".parameterize.to_sym unless tab_id @tab_name = tab_name @options = options @header = view_context.content_tag :li, class: (options[:first] ? 'active' : '') do view_context.link_to(@tab_name, "##{@tab_id}") end @content = ''.html_safe yield(self) end def tab_header(&block) @header = block_given? ? @view_context.capture(&block) : '' end def tab_content(&block) @content = block_given? ? @view_context.capture(&block) : '' end end end