Module: OodAppkit::MarkdownTemplateHandler

Defined in:
lib/ood_appkit/markdown_template_handler.rb

Overview

Class used to handle markdown views in ‘ActionView::Template`

Class Method Summary collapse

Class Method Details

.call(_, source) ⇒ String

String of ruby code to be evaluated when rendering the view

Parameters:

  • template (ActionView::Template)

    the template to be rendered

Returns:

  • (String)

    string of ruby code to be evaluated



7
8
9
# File 'lib/ood_appkit/markdown_template_handler.rb', line 7

def self.call(_, source)
  "begin;#{render(source)}.html_safe;end"
end

.render(text) ⇒ String

Render markdown to HTML

Parameters:

  • text (String)

    markdown text

Returns:

  • (String)

    escaped version of html text surrounded by quote marks



14
15
16
# File 'lib/ood_appkit/markdown_template_handler.rb', line 14

def self.render(text)
  markdown.render(text).inspect
end