Sha256: c1655b3e52f4293fa408f88ec9173016595255a28af2d59b1181a3e1b8ee76c4

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

require "action_view"
require "action_view/template"
require "redcarpet"
require "markerb/railtie"

module Markerb
  mattr_accessor :processing_options, :renderer
  @@processing_options = {}
  @@renderer = Redcarpet::Render::HTML

  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)
        "Redcarpet::Markdown.new(Markerb.renderer, Markerb.processing_options).render(begin;#{compiled_source};end).html_safe"
      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-1.0.2 lib/markerb.rb