Module: Plum::Cp::ThemeSettingsHelper

Defined in:
app/helpers/plum/cp/theme_settings_helper.rb

Instance Method Summary collapse

Instance Method Details

#theme_setting_label(field) ⇒ Object



4
5
6
# File 'app/helpers/plum/cp/theme_settings_helper.rb', line 4

def theme_setting_label(field)
  field["label"].presence || field["handle"].to_s.humanize
end

#theme_setting_options(field) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/plum/cp/theme_settings_helper.rb', line 8

def theme_setting_options(field)
  Array(field["options"]).filter_map do |option|
    if option.is_a?(Hash)
      normalized = option.deep_stringify_keys
      value = normalized["value"].to_s
      next if value.blank?

      [ normalized["label"].presence || value.humanize, value ]
    else
      value = option.to_s
      next if value.blank?

      [ value.humanize, value ]
    end
  end
end