Sha256: ad369a4126f261de282530b98a71f073eb37036f00c25bb4d2731b6798a36534

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

require 'malt/engines/abstract'

module Malt::Engine

  # RagTag
  #
  #  http://github.com/rubyworks/ragtag
  #
  class RagTag < Abstract

    default :ragtag, :rt

    #
    def render(params, &yld)
      text = params[:text]
      file = params[:file]
      data = params[:data]
      into = params[:to]

      case into
      when :html, nil
        data = make_binding(data, &yld)
        intermediate(params).compile(data).to_xhtml
      when :xml
        data = make_binding(data, &yld)
        intermediate(params).compile(data).to_xml
      else
        super(params, &yld)
      end
    end

    #
    def intermediate(params)
      text = params[:text]
      ::RagTag.new(text)
    end

    private

    # Load Haml library if not already loaded.
    def initialize_engine
      return if defined? ::RagTag
      require_library 'ragtag'
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

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