Sha256: 0b170743bbfa8e31997e012194bf25ff2d1621ce8d19142d753f50d9647b3d7a

Contents?: true

Size: 624 Bytes

Versions: 6

Compression:

Stored size: 624 Bytes

Contents

require 'action_view'
module ActionView
  module Template::Handlers
    class AxlsxBuilder
      def default_format
        Mime::XLSX
      end

      def self.call(template)
        "xlsx_package = Axlsx::Package.new(:author => #{axlsx_author.inspect});\n" +
          template.source +
          ";\nxlsx_package.to_stream.string;"
      end

      private

      def self.axlsx_author
        Rails.application.config.respond_to?(:axlsx_author) ? Rails.application.config.axlsx_author : nil
      end
    end
  end
end

ActionView::Template.register_template_handler :axlsx, ActionView::Template::Handlers::AxlsxBuilder

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
axlsx_rails-0.2.0 lib/axlsx_rails/template_handler.rb
axlsx_rails-0.1.5 lib/axlsx_rails/template_handler.rb
axlsx_rails-0.1.4 lib/axlsx_rails/template_handler.rb
axlsx_rails-0.1.3 lib/axlsx_rails/template_handler.rb
axlsx_rails-0.1.2 lib/axlsx_rails/template_handler.rb
axlsx_rails-0.1.1 lib/axlsx_rails/template_handler.rb