Created
May 4, 2011 18:05
-
-
Save sleepingkingstudios/955676 to your computer and use it in GitHub Desktop.
Adding a :redcarpet Haml Filter to Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A revised version based on this at: https://gist.github.com/peterwake/46b2a2397abff714aea4431491ef9a3e