Module: Comfy::Admin::CmsHelper

Defined in:
app/helpers/comfy/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, … }}



42
43
44
45
# File 'app/helpers/comfy/admin/cms_helper.rb', line 42

def cms_file_link_tag(file)
  as = ", as: image" if file.attachment.image?
  "{{ cms:file_link #{file.id}#{as} }}"
end

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

Injects some content somewhere inside cms admin area



26
27
28
# File 'app/helpers/comfy/admin/cms_helper.rb', line 26

def cms_hook(name, options = {})
  ComfortableMexicanSofa::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, … }}



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

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

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



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

def comfy_admin_partial(path, params = {})
  render path, params
rescue ActionView::MissingTemplate
  if ComfortableMexicanSofa.config.reveal_cms_partials
    (:div, class: "comfy-admin-partial") do
      path
    end
  end
end

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

Wrapper around ComfortableMexicanSofa::FormBuilder



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

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