require "action_view/template" require "kramdown" require "markerb/railtie" module Markerb class Handler def erb_handler @erb_handler ||= ActionView::Template.registered_template_handler(:erb) end def call(template) compiled_source = erb_handler.call(template) if template.formats.include?(:html) "Kramdown::Document.new(begin;#{compiled_source};end).to_html" else compiled_source end end end end ActionView::Template.register_template_handler :markerb, Markerb::Handler.new