Sha256: 1fd420d75d4e2ea44bc40f9e164360d87fc835f076aa7569a5c06f3b47973647

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

# Rails 2.X Template
if Rails.version =~ /^2/
  require 'action_view/base'
  require 'action_view/template'

  module ActionView
    module TemplateHandlers
      class OsheetHandler < TemplateHandler
        include Compilable

        def compile(template)
          # template.format => 'xls' (or xlsx or whatever they specify)
          %{::Osheet::Workbook.new {#{template.source}\n }.to_data}
        end

      end
    end
  end

  ::ActionView::Template.register_template_handler :osheet, ActionView::TemplateHandlers::OsheetHandler
end

# Rails 3.X Template
if Rails.version =~ /^3/
  require 'action_view/base'
  require 'action_view/template'

  module ActionView
    module Template::Handlers
      class OsheetHandler < Template::Handler
        include Compilable

        self.default_format = Osheet::MIME_TYPE
        def compile(template)
          # template.format => 'xls' (or xlsx or whatever they specify)
          %{::Osheet::Workbook.new {\n#{template.source}\n }.to_data}
        end

      end
    end
  end

  ::ActionView::Template.register_template_handler :osheet, ActionView::Template::Handlers::OsheetHandler
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
osheet-0.10.0 lib/osheet/view_handler/rails.rb
osheet-0.9.2 lib/osheet/view_handler/rails.rb
osheet-0.9.1 lib/osheet/view_handler/rails.rb
osheet-0.9.0 lib/osheet/view_handler/rails.rb
osheet-0.8.0 lib/osheet/view_handler/rails.rb
osheet-0.7.0 lib/osheet/view_handler/rails.rb
osheet-0.6.0 lib/osheet/view_handler/rails.rb
osheet-0.5.0 lib/osheet/template_handler/rails.rb