Module: Markdownable::ClassMethods
- Defined in:
- lib/markdownable.rb
Instance Method Summary collapse
Instance Method Details
#markdownable(*fields) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/markdownable.rb', line 6 def markdownable(*fields) fields.each do |field| define_method "#{field}_markdown" do renderer = Redcarpet::Render::HTML.new(:hard_wrap => true) markdown = Redcarpet::Markdown.new(renderer, :autolink => true, :lax_html_blocks => true) text = self.send(field) markdown.render(text) unless text.nil? end end end |