Sha256: 52f06949f291f8aeb11ec3f76ac9122787bba7cc6c6f2acfe885c8486f24b9b5

Contents?: true

Size: 746 Bytes

Versions: 17

Compression:

Stored size: 746 Bytes

Contents

# frozen_string_literal: true

# 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: form_field_id, 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

17 entries across 17 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 lib/comfortable_mexican_sofa/content/tags/markdown.rb
PixelForce_ETS-0.0.2 lib/comfortable_mexican_sofa/content/tags/markdown.rb
PixelForce_ETS-0.0.1 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest2-0.0.4 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest2-0.0.3 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest2-0.0.2 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest2-0.0.1 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest-0.0.1 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcyEtsTest-2.2.19 lib/comfortable_mexican_sofa/content/tags/markdown.rb
ComfortableMexicanSofa-2.0.18 lib/comfortable_mexican_sofa/content/tags/markdown.rb
kcy1-1.0 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.18 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.17 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.16 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.15 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.14 lib/comfortable_mexican_sofa/content/tags/markdown.rb
comfortable_mexican_sofa-2.0.13 lib/comfortable_mexican_sofa/content/tags/markdown.rb