Skip to content

Instantly share code, notes, and snippets.

@sleepingkingstudios
Created May 4, 2011 18:05
Show Gist options
  • Save sleepingkingstudios/955676 to your computer and use it in GitHub Desktop.
Save sleepingkingstudios/955676 to your computer and use it in GitHub Desktop.
Adding a :redcarpet Haml Filter to Rails
# Thanks to:
# http://stackoverflow.com/questions/1921777/how-to-write-a-haml-custom-filter
# config/initializers/haml_filters.rb
require 'haml/filters/redcarpet'
# lib/haml/filters/redcarpet.rb
require 'redcarpet'
module Haml::Filters::Redcarpet
include Haml::Filters::Base
def render(text)
markdown = Redcarpet.new(text)
return markdown.to_html
end # method render
end # module Haml::Filters::Redcarpet
@peterwake
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment