-
-
Save jeremyruppel/2884971 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 | |
def call( template ) | |
renderer.render( template.source ).inspect | |
end | |
protected | |
def renderer | |
@renderer ||= begin | |
::Redcarpet::Markdown.new ::Redcarpet::Render::HTML, markdown_options | |
end | |
end | |
def markdown_options | |
{ :autolink => true, :fenced_code_blocks => true } | |
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