Module: Occams::Admin::CmsHelper

Defined in:
app/helpers/occams/admin/cms_helper.rb

Instance Method Summary collapse

Instance Method Details

Returns cms:file_link #{file.id, … }}.

Parameters:

Returns:

  • (String)

    cms:file_link #{file.id, … }}



41
42
43
44
45
46
47
# File 'app/helpers/occams/admin/cms_helper.rb', line 41

def cms_file_link_tag(file)
  if file.attachment.image?
    "{{ cms:image #{file.label} }}"
  else
    "{{ cms:file_link #{file.id} }}"
  end
end

#cms_hook(name, options = {}) ⇒ Object

Injects some content somewhere inside cms admin area



25
26
27
# File 'app/helpers/occams/admin/cms_helper.rb', line 25

def cms_hook(name, options = {})
  Occams::ViewHooks.render(name, self, options)
end

Returns cms:page_file_link #{fragment_id, … }}.

Parameters:

  • fragment_id (String)
  • attachment (ActiveStorage::Blob)
  • multiple (Boolean)

Returns:

  • (String)

    cms:page_file_link #{fragment_id, … }}



33
34
35
36
37
# File 'app/helpers/occams/admin/cms_helper.rb', line 33

def cms_page_file_link_tag(fragment_id:, attachment:, multiple:)
  filename  = ", filename: \"#{attachment.filename}\""  if multiple
  as        = ', as: image'                             if attachment.image?
  "{{ cms:page_file_link #{fragment_id}#{filename}#{as} }}"
end

#occams_admin_partial(path, params = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/helpers/occams/admin/cms_helper.rb', line 14

def occams_admin_partial(path, params = {})
  render path, params
rescue ActionView::MissingTemplate
  if Occams.config.reveal_cms_partials
    (:div, class: 'occams-admin-partial') do
      path
    end
  end
end

#occams_form_with(**options, &block) ⇒ Object

Wrapper around Occams::FormBuilder



7
8
9
10
11
12
# File 'app/helpers/occams/admin/cms_helper.rb', line 7

def occams_form_with(**options, &block)
  form_options = options.merge(builder: Occams::FormBuilder)
  form_options[:bootstrap]  = { layout: :horizontal }
  form_options[:local]      = true
  bootstrap_form_with(**form_options, &block)
end