Sha256: c1afa51c5198b6dfcb11aa853a5b7ad177e1e74ef78093b2614848db50524aec

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

Tableview
=========


Tableview is a gem to be used in Rails to create table like views.

Installation
============


In your Gemfile:


    gem 'tableview'
     
then

    $ bundle install
    $ rails g tableview:install
     
To apply to a resource use the built in generator:

    $ rails g tableview resource_name

This will create a partial named `_table.tv` in which you can use a DSL like this to define your table:

    => @registrations
    
    + :first_name
    + :surname
    + :address {|reg| reg.address + "\n" + reg.postcode }
    + :friends if format.html?
    
    if format.xls?
      = @registrations.some_scope, "Workbook title"
      = @registration.other_scope, "Works as title in other formats as well"
    end
    
The DSL is a simple superset of ruby with a few special characters (only work if first printable character on line, won't work with eval and friends).

Character | Meaning
----------|--------
 `=>`     | Use the passed collection for rendering and I18n
 `*`      | Pass a hash to this, is used to configure the formatters.
 `+`      | Defines a column. If passed a symbol, Tableview will use I18n to lookup the header and call the method on the model to get the value. Strings will be used literally. Optionally use a block to generate values.
 `=`      | Render a subtable for the passed collection. Not all formatters support subtables, use at own risk (notably the CSV formatter has no support for this). Is meant mainly to have nice full-featured excel files.
 
It will also add a few lines of code to your controller:

- `self.responder = ApplicationResponder` this sets up the correct code path to use for dynamically rendering all the formats.
- `respond_to :html, :json, :csv, :xls, :ascii` a list of supported formats. You will want to use `respond_with` as well.

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tableview-0.3.3 README.md
tableview-0.3.2 README.md
tableview-0.3.1 README.md
tableview-0.3.0 README.md