mudge (owner)

Forks

Revisions

gist: 22874 Download_button fork
public
Description:
Maruku helper for Rails.
Public Clone URL: git://gist.github.com/22874.git
Embed All Files: show embed
application_helper.rb #
1
2
3
4
5
6
7
8
9
10
11
# For Rails 2.3.2 or earlier.
require 'maruku' # or use config.gem "maruku" in environment.rb

module ApplicationHelper
  
  # Replacement for Rails' default Markdown helper which uses Maruku instead
  # of BlueCloth.
  def markdown(text)
    text.blank? ? "" : Maruku.new(text).to_html
  end
end
maruku.rb #
1
2
3
4
5
# For Rails 2.3.3 or later.
# Add a gem dependency on "maruku" with either config.gem or your Gemfile
# (depending on your version of Rails) and then add this file to
# config/initializers/
Markdown = Maruku unless defined?(Markdown)

2 Comments

hron84 commented

Sat Jul 17 08:58:04 -0700 2010

It is unneeded.
Create an initializer with content:

Markdown = Maruku unless defined? Markdown

and you will be happy.

mudge commented gist owner

Tue Jul 20 02:26:12 -0700 2010

hron84, thanks for the heads up: it seems that the markdown helper was changed in Rails 2.3.3 so that it is no longer hard-coded as BlueCloth. I've added your initializer above and commented that the helper override is only needed for older versions of Rails.

Please log in to comment.