I was reading through Redcarpet's documentation and came across this sentence:
The Markdown object is encouraged to be instantiated once with the required settings, and reused between parses.
What is the best way to go about doing this in a Rails
app?
I watched Ryan Bates' railscast on Redcarpet and he has a helper method in application_helper.rb
where every method call instantiates a new Redcarpet
object, like so:
def markdown(text)
options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
Redcarpet.new(text, *options).to_html.html_safe
end
Is this not the best way to go about doing this? Thanks for any advice.