README.md

Table Cloth

Table Cloth gives you an easy to use DSL for creating and rendering tables in rails.

The primary goal of Table Cloth is to remove the complexity that usually comes with making tables with dynamic content.
HTML Tables frequently can get out of hand when you start to add conditionals, removing columns, etc..

Installation

Usage

Table Cloth can use defined tables in app/tables or you can build them on the fly.

Table models can be generated using rails generators.

$ rails g table User

It will make this:

classUserTable < TableCloth::Base# Define columns with the #column method# column :name, :email# Columns can be provided a block## column :name do |object|# object.name.downcase# end## Columns can also have conditionals if you want.# The conditions are checked against the table's methods.# As a convience, the table has a #view method which will return the current view context.# This gives you access to current user, params, etc...## column :email, if: :admin?## def admin?# view.current_user.admin?# end## Actions give you the ability to create a column for any actions you'd like to provide.# Pass a block with an arity of 2, (object, view context).# You can add as many actions as you want.## actions do# action {|object| link_to "Edit", edit_object_path(object) }# endend