Class: OkonomiUiKit::AttributeSectionHelper::AttributeSectionBuilder
- Inherits:
-
Object
- Object
- OkonomiUiKit::AttributeSectionHelper::AttributeSectionBuilder
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper
- Defined in:
- app/helpers/okonomi_ui_kit/attribute_section_helper.rb
Instance Method Summary collapse
- #attribute(label, value = nil, **options, &block) ⇒ Object
-
#initialize(template) ⇒ AttributeSectionBuilder
constructor
A new instance of AttributeSectionBuilder.
Constructor Details
#initialize(template) ⇒ AttributeSectionBuilder
Returns a new instance of AttributeSectionBuilder.
18 19 20 |
# File 'app/helpers/okonomi_ui_kit/attribute_section_helper.rb', line 18 def initialize(template) @template = template end |
Instance Method Details
#attribute(label, value = nil, **options, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/okonomi_ui_kit/attribute_section_helper.rb', line 22 def attribute(label, value = nil, **, &block) content = if block_given? capture(&block) elsif value.respond_to?(:call) value.call else value end tag.div(class: "py-6 sm:grid sm:grid-cols-3 sm:gap-4") do dt_content = tag.dt(label, class: "text-sm font-medium text-gray-900") dd_content = tag.dd(content, class: "mt-1 text-sm/6 text-gray-700 sm:col-span-2 sm:mt-0") dt_content + dd_content end end |