Skip to content

Instantly share code, notes, and snippets.

@chooh
Created December 29, 2011 14:36
Show Gist options
  • Save chooh/1534361 to your computer and use it in GitHub Desktop.
Save chooh/1534361 to your computer and use it in GitHub Desktop.
Markdown handler with erb support
# put me in config/initializers/rdiscount.rb
class ActionView::Template
class RDiscountHandler < Handler
def self.erb_handler
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template)
compiled_source = erb_handler.call(template)
"::RDiscount.new(begin;#{compiled_source};end).to_html"
end
end
register_template_handler :markdown, RDiscountHandler
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment