Sha256: 9e3cbd588b9c8dbd2acacc6a6eca13f791cd4ffe6a592e294baf7193d1a149d0
Contents?: true
Size: 875 Bytes
Versions: 18
Compression:
Stored size: 875 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 content_tag(:dt, text) concat content_tag(:dd, value) end end end def definition_list_for(model, size: :large) content_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