module SimpleModelView::TemplateHelpers

Public Instance Methods

blank_span() click to toggle source
# File lib/simple_model_view/template_helpers.rb, line 9
def blank_span
  template.content_tag :span, I18n.t('simple_model_view.empty'), class: :empty
end
block_concat() { || ... } click to toggle source
# File lib/simple_model_view/template_helpers.rb, line 5
def block_concat
  template.concat yield
end
merge_html_attrs(default, input) click to toggle source
# File lib/simple_model_view/template_helpers.rb, line 13
def merge_html_attrs(default, input)
  result = default.transform_keys(&:to_sym)
  input = input.transform_keys(&:to_sym)

  if result[:data].is_a?(Hash) && input[:data].is_a?(Hash)
    input[:data] = result[:data].merge(input[:data])
  end

  if result[:class] && input[:class]
    input[:class] = [*default[:class], *input[:class]]
  end

  result.merge! input
  result.compact!
  result
end