Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyruppel/2884971 to your computer and use it in GitHub Desktop.
Save jeremyruppel/2884971 to your computer and use it in GitHub Desktop.
RedCarpet Rails Template Handler
# 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