Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made it possible to pass settings to the renderer.

  • Loading branch information...
commit ae694932ffef1255287c5cb360910c1176deb78c 1 parent e112976
Nicholas Jakobsen njakobsen authored
12 app/helpers/editable_contents_helper.rb
... ... @@ -1,6 +1,12 @@
1 1 module EditableContentsHelper
2   - def markdown(string)
3   - @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, :tables => true, :autolink => true, :space_after_headers => true)
4   - @markdown.render(string).html_safe
  2 + def markdown(string, options = nil)
  3 + options ||= {:tables => true, :autolink => true, :space_after_headers => true, :hard_wrap => true}
  4 + @markdown_renderers ||= {}
  5 +
  6 + unless renderer = @markdown_renderers[options]
  7 + renderer = @markdown_renderers[options] = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(options), options)
  8 + end
  9 +
  10 + renderer.render(string).html_safe
5 11 end
6 12 end
4 app/models/editable_content.rb
@@ -21,8 +21,8 @@ def to_s
21 21 self.body
22 22 end
23 23
24   - def to_html
25   - markdown(self.body)
  24 + def to_html(options = nil)
  25 + markdown(self.body, options)
26 26 end
27 27
28 28 private

0 comments on commit ae69493

Please sign in to comment.
Something went wrong with that request. Please try again.