Class: LcpRuby::Display::Renderers::Markdown

Inherits:
BaseRenderer show all
Defined in:
lib/lcp_ruby/display/renderers/markdown.rb

Instance Method Summary collapse

Instance Method Details

Returns:

  • (Boolean)


20
21
22
# File 'lib/lcp_ruby/display/renderers/markdown.rb', line 20

def link_producing?
  true
end

#render(value, options = {}, record: nil, view_context: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lcp_ruby/display/renderers/markdown.rb', line 8

def render(value, options = {}, record: nil, view_context: nil)
  return nil if value.blank?

  html = Commonmarker.to_html(value.to_s,
    options: LcpRuby::Display::MarkdownSanitize::COMMONMARKER_OPTIONS)
  view_context.(:div,
    view_context.sanitize(html,
      tags: LcpRuby::Display::MarkdownSanitize::TAGS,
      attributes: LcpRuby::Display::MarkdownSanitize::ATTRIBUTES),
    class: "lcp-markdown")
end