Sha256: f2e636c9c4f3599d16b20a80e010d48d1af04965412bcd838024691cb2485f62

Contents?: true

Size: 705 Bytes

Versions: 10

Compression:

Stored size: 705 Bytes

Contents

# Tag for text content that is going to be rendered using textarea with markdown
#   {{ cms:markdown identifier }}
#
class ComfortableMexicanSofa::Content::Tag::Markdown < ComfortableMexicanSofa::Content::Tag::Fragment

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

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

    yield input
  end

end

ComfortableMexicanSofa::Content::Renderer.register_tag(
  :markdown, ComfortableMexicanSofa::Content::Tag::Markdown
)

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.12 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.11 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.10 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.9 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.8 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.7 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.6 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.5 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.4 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.3 lib/comfortable_mexican_sofa/content/tags/markdown.rb