Sha256: 6896b7d666e973d7543858728ef0738b8bcfedd17d4b4e30a60f38e3fb50ebd7

Contents?: true

Size: 765 Bytes

Versions: 5

Compression:

Stored size: 765 Bytes

Contents

module Htmltoword
  class Railtie < ::Rails::Railtie
    initializer 'htmltoword.setup' do
      if defined?(Mime) and Mime[:docx].nil?
        Mime::Type.register 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', :docx
      end

      ActionController::Renderers.add :docx do |file_name, options|
        Htmltoword::Renderer.send_file(self, file_name, options)
      end

      if defined? ActionController::Responder
        ActionController::Responder.class_eval do
          def to_docx
            if @default_response
              @default_response.call(options)
            else
              controller.render({ docx: controller.action_name }.merge(options))
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
htmltoword-1.1.1 lib/htmltoword/railtie.rb
janie-htmltoword-1.1.2 lib/htmltoword/railtie.rb
htmltoword-1.1.0 lib/htmltoword/railtie.rb
htmltoword-1.0.0 lib/htmltoword/railtie.rb
htmltoword-0.7.0 lib/htmltoword/railtie.rb