Sha256: cf0aadee891ec5077fb8bbdaaf1ac7781efbf4ef559dda91e18a6fa6dcbb14bc
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Para module FormBuilder module Tabs def tabs(&block) tabs_manager = TabsManager.new(template, object) block.call(tabs_manager) template.render partial: 'para/form/tabs', locals: { tabs: tabs_manager.tabs } end class TabsManager attr_reader :template, :object def initialize(template, object) @template = template @object = object end def tab(identifier, options = {}, &block) tabs << Tab.new(template, object, identifier, options, &block) nil end def tabs @tabs ||= [] end end class Tab attr_reader :template, :object, :identifier, :icon, :content delegate :capture, to: :template def initialize(template, object, identifier, options, &content_block) @template = template @object = object @identifier = identifier @content = capture { content_block.call } @icon = options[:icon] end def title if Symbol === identifier I18n.t("forms.tabs.#{ object.class.model_name.i18n_key }.#{ identifier }") else identifier end end def dom_id @dom_id = identifier.to_s.parameterize end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
para-0.5.1 | lib/para/form_builder/tabs.rb |
para-0.5.0 | lib/para/form_builder/tabs.rb |