Sha256: 574fee7074bfc6a268afe195c4ea57952da1db8431d99964382f590550107d38

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
markerb-pure-0.1.0 lib/markerb.rb