if !defined?(ActionView) raise "All of this only makes sense within rails" end require "erb" require "rdiscount" class ActionView::MdownHandler < ActionView::TemplateHandler def render(template, local_assigns) txt = ERB.new(template.source).result(@view.send(:binding)) RDiscount.new(txt).to_html end end ActionView::Template.register_template_handler :mdown, ActionView::MdownHandler