Module: Locomotive::Shared::SiteMetafieldsHelper

Defined in:
app/helpers/locomotive/shared/site_metafields_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_site_metafields_uiObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/locomotive/shared/site_metafields_helper.rb', line 5

def current_site_metafields_ui
  return @site_metafields_ui if @site_metafields_ui

  _ui = current_site.metafields_ui

  @site_metafields_ui = {}.tap do |ui|
    # label displayed in the sidebar section
    ui[:label] = current_site_metafields_ui_t(_ui['label'], t('locomotive.shared.sidebar.metafields'))

    # top title displayed in the metafields view
    ui[:title] = current_site_metafields_ui_t(_ui['label'], t('locomotive.current_site_metafields.index.title'))

    # hint for the editing properties page
    ui[:hint]  = current_site_metafields_ui_t(_ui['hint'], t('locomotive.current_site_metafields.index.help', default: ''))

    # icon in the sidebar
    ui[:icon]  = "fas fa-#{_ui['icon'].present? ? _ui['icon'] : 'newspaper'}"
  end
end

#current_site_metafields_ui_t(value, default = nil) ⇒ Object


25
26
27
28
29
30
31
# File 'app/helpers/locomotive/shared/site_metafields_helper.rb', line 25

def current_site_metafields_ui_t(value, default = nil)
  (if value.is_a?(Hash)
    value[I18n.locale.to_s] || value['default']
  else
    value
  end || default).html_safe
end