Module: LeanCms::ContentHelper
- Defined in:
- app/helpers/lean_cms/content_helper.rb
Instance Method Summary collapse
-
#can_edit_cms? ⇒ Boolean
Check if current user can edit CMS content.
-
#cms_edit_link(path, text: "Edit", css_class: "") ⇒ Object
Show edit link if user is CMS editor.
-
#render_editable_section(page_key, section_key, default: nil, **options) ⇒ Object
Render editable content section.
Instance Method Details
#can_edit_cms? ⇒ Boolean
Check if current user can edit CMS content
23 24 25 |
# File 'app/helpers/lean_cms/content_helper.rb', line 23 def can_edit_cms? current_user&. end |
#cms_edit_link(path, text: "Edit", css_class: "") ⇒ Object
Show edit link if user is CMS editor
28 29 30 31 32 |
# File 'app/helpers/lean_cms/content_helper.rb', line 28 def cms_edit_link(path, text: "Edit", css_class: "") return unless can_edit_cms? link_to text, path, class: "cms-edit-link #{css_class}".strip end |
#render_editable_section(page_key, section_key, default: nil, **options) ⇒ Object
Render editable content section
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/lean_cms/content_helper.rb', line 4 def render_editable_section(page_key, section_key, default: nil, **) content = LeanCms::PageContent.for_section(page_key, section_key) if content.persisted? case content.content_type.to_sym when :rich content_tag(:div, content.rich_content, **) when :markdown # TODO: Add markdown rendering with a gem like Redcarpet content_tag(:div, simple_format(content.content), **) else content_tag(:div, content.content, **) end else default end end |