Module: Envoy::Markdown

Defined in:
lib/envoy/markdown.rb

Overview

Renders Markdown to sanitized HTML. A plain module method (NOT a view helper) so it works in any render context — including Turbo broadcasts, which render partials through the host's ApplicationController and cannot see engine view helpers. Call directly from partials: <%= Envoy::Markdown.render(text) %>.

Class Method Summary collapse

Class Method Details

.render(text) ⇒ Object



11
12
13
14
# File 'lib/envoy/markdown.rb', line 11

def render(text)
  return "".html_safe if text.blank?
  Commonmarker.to_html(text, options: { render: { unsafe: false } }).html_safe
end