Sha256: ecfdcf64c172b1de4b86e2d4340743e3a34ce2c4164ac5e8b3df6602d20d51f0
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Koi module SummaryList class Base < ViewComponent::Base include Katalyst::HtmlAttributes define_html_attribute_methods :term_attributes, default: {} define_html_attribute_methods :description_attributes, default: {} def initialize(model, attribute, label: nil, skip_blank: true) super() @model = model @attribute = attribute @label = label @skip_blank = skip_blank end def call tag.dt(attribute_name, **term_attributes) + tag.dd(attribute_value, **description_attributes) end def render? raw_value.present? || !@skip_blank end def attribute_name @label&.dig(:text) || @model.class.human_attribute_name(@attribute) end def attribute_value raw_value.to_s end def raw_value @model.public_send(@attribute) end def inspect "#<#{self.class.name} #{@attribute.inspect}>" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
katalyst-koi-4.5.0.beta.1 | app/components/koi/summary_list/base.rb |
katalyst-koi-4.4.1 | app/components/koi/summary_list/base.rb |
katalyst-koi-4.4.0 | app/components/koi/summary_list/base.rb |