Sha256: 48f2885344dc4e08eddc1ae70a01e4f3d76420c415302631714bae4a100929d4

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

module Tableview
  class TV 
    def call(template)
      source = template.source
      start, ending = /^\s*/, /\s+(.+?)(?= unless| if| do|\{|#|$)/
      source.gsub!(/#{start}\+#{ending}/, 'table.column(\1)')
      source.gsub!(/#{start}\=>#{ending}/, 'table.table_for(\1)')
      source.gsub!(/#{start}\=#{ending}/, 'table.generate_subtable_for(\1)')
      source.gsub!(/#{start}\*#{ending}/, 'table.config(\1)')
      %{
        format = Tableview::Helper::Format.new(params)
        tv = Tableview::ViewHandler.table do |table|
          #{source}
        end
        output = Tableview::output_class(params[:format]).new
        output.process(tv)
        output.to_s
      }
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tableview-0.4.0 lib/tableview/tv.rb