Sha256: 7ebb3eb8539be7399941d0ef0fc7d9a58ef1093f417cfd27d73c6dc1bbd34ed4

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

module WorkbookRails
  class TemplateHandler
    class_attribute :default_format
    self.default_format = :xlsx

    def self.workbook_to_string(workbook, format)
      case format
      when :xlsx then workbook.stream_xlsx
      when :xls then
        io = StringIO.new
        workbook.to_xls.write(io)
        io.string
      end
    end

    def self.call(template)
      "workbook = Workbook::Book.new;\n" +
      template.source +
      ";\nWorkbookRails::TemplateHandler.workbook_to_string(workbook, lookup_context.rendered_format);"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workbook_rails-0.1.0 lib/workbook_rails/template_handler.rb