Sha256: 6aa22b26e55dfca9e00804985c750afa98264b120ac3e745eda8bb514fa4aba5

Contents?: true

Size: 907 Bytes

Versions: 2

Compression:

Stored size: 907 Bytes

Contents

require 'malt/engines/abstract'

module Malt::Engine

  # RDoc template.
  #
  #   http://rdoc.rubyforge.org/
  #
  # It's suggested that your program require 'rdoc/markup' and
  # 'rdoc/markup/to_html' at load time when using this template
  # engine.
  class RDoc < Abstract

    default :rdoc

    # Convert rdoc text to html.
    def render(params)
      text = params[:text]
      into = params[:to]
      case into
      when :html, nil
        html_engine.convert(text).to_s
      else
        super(params)
      end
    end

    private

      # Load rdoc makup library if not already loaded.
      def initialize_engine
        return if defined?(::RDoc::Markup)
        require 'rubygems' # hack
        require_library 'rdoc/markup'
        require_library 'rdoc/markup/to_html'
      end

      #
      def html_engine
        @html_engine ||= ::RDoc::Markup::ToHtml.new
      end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
malt-0.3.0 lib/malt/engines/rdoc.rb
malt-0.2.0 lib/malt/engines/rdoc.rb