Sha256: 25394958170096b886077279fa741aaf09d9b64de3117943117a6d46e43e00f5

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require 'malt/engines/abstract'

module Malt::Engines

  # 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]
      format = params[:format]
      case format
      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

1 entries across 1 versions & 1 rubygems

Version Path
malt-0.1.0 lib/malt/engines/rdoc.rb