class ComfortableMexicanSofa::Content::Tag::Markdown

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

{{ cms:markdown identifier }}

Public Instance Methods

form_field(object_name, view, index) { |input| ... } click to toggle source
# 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
render() click to toggle source
# File lib/comfortable_mexican_sofa/content/tags/markdown.rb, line 8
def render
  renderable ? Kramdown::Document.new(content.to_s).to_html : ""
end