Sha256: f88c3d285931da19f8b9c1f2c4f2459261e6e983b957c9610e5fc408101c373f
Contents?: true
Size: 845 Bytes
Versions: 18
Compression:
Stored size: 845 Bytes
Contents
# frozen_string_literal: true module Renalware module DefinitionListHelper class DefinitionList < SimpleDelegator include ActionView::Helpers::TagHelper include ActionView::Helpers::TextHelper include ActionView::Context def initialize(model) @model_klass = model.class super(model) end def definition(attribute, label = nil) text = label || @model_klass.human_attribute_name(attribute) value = __getobj__.public_send(attribute) value = yield(value) if value.present? && block_given? capture do concat tag.dt(text) concat tag.dd(value) end end end def definition_list_for(model, size: :large) tag.dl(class: "dl-horizontal #{size}") do yield DefinitionList.new(model) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems