Created
February 2, 2012 00:37
-
-
Save jamesarosen/1720423 to your computer and use it in GitHub Desktop.
RedCarpet Rails Template Handler
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
# This version works in Rails 3.2 | |
require 'redcarpet' | |
class ActionView::Template | |
class Redcarpet | |
class <<self | |
def renderer | |
@renderer ||= ::Redcarpet::Markdown.new( | |
::Redcarpet::Render::HTML, | |
:autolink => true, | |
:fenced_code_blocks => true | |
) | |
end | |
end | |
def call(template) | |
self.class.renderer.render(template.source).inspect | |
end | |
end | |
register_template_handler :md, Redcarpet.new | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment