Class: ComfortableMexicanSofa::Content::Tag::Markdown

Inherits:
Fragment show all
Defined in:
lib/comfortable_mexican_sofa/content/tags/markdown.rb

Overview

Tag for text content that is going to be rendered using textarea with markdown

{{ cms:markdown identifier }}

Instance Attribute Summary

Attributes inherited from Fragment

#identifier, #namespace, #options, #renderable

Attributes inherited from ComfortableMexicanSofa::Content::Tag

#context, #params, #source

Instance Method Summary collapse

Methods inherited from Fragment

#content, #form_field_id, #fragment, #initialize

Methods inherited from ComfortableMexicanSofa::Content::Tag

#allow_erb?, #content, #initialize, #nodes

Constructor Details

This class inherits a constructor from ComfortableMexicanSofa::Content::Tag::Fragment

Instance Method Details

#form_field(object_name, view, index) {|input| ... } ⇒ Object

Yields:

  • (input)

12
13
14
15
16
17
18
# File 'lib/comfortable_mexican_sofa/content/tags/markdown.rb', line 12

def form_field(object_name, view, index)
  name    = "#{object_name}[fragments_attributes][#{index}][content]"
  options = { id: form_field_id, data: { "cms-cm-mode" => "text/x-markdown" } }
  input   = view.send(:text_area_tag, name, content, options)

  yield input
end

#renderObject


8
9
10
# File 'lib/comfortable_mexican_sofa/content/tags/markdown.rb', line 8

def render
  renderable ? Kramdown::Document.new(content.to_s).to_html : ""
end