Module: HasMarkup::Markdown

Defined in:
lib/has_markup/markdown.rb

Overview

Provides HasMarkup with markdown support.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Instance Method Details

#sprinkle_markdown_magic(column) ⇒ Object

Sprinkles the magic needed to support markdown. In particular, it will validate the markdown syntax on the column, and define a method column_html which uses BlueCloth to generate HTML.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/has_markup/markdown.rb', line 6

def sprinkle_markdown_magic(column)
  require 'bluecloth'

  extend HasMarkup::Markdown::ClassMethods
  include HasMarkup::Markdown::InstanceMethods

  validates_markdown_syntax column
  define_method "#{column}_html" do
    markdown = self.send(column)
    self.generate_html_from_markdown(markdown)
  end
end