Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -1,6 +1,12 @@
module EditableContentsHelper
- def markdown(string)
- @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, :tables => true, :autolink => true, :space_after_headers => true)
- @markdown.render(string).html_safe
+ def markdown(string, options = nil)
+ options ||= {:tables => true, :autolink => true, :space_after_headers => true, :hard_wrap => true}
+ @markdown_renderers ||= {}
+
+ unless renderer = @markdown_renderers[options]
+ renderer = @markdown_renderers[options] = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(options), options)
+ end
+
+ renderer.render(string).html_safe
end
end
4 app/models/editable_content.rb
View
@@ -21,8 +21,8 @@ def to_s
self.body
end
- def to_html
- markdown(self.body)
+ def to_html(options = nil)
+ markdown(self.body, options)
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.