patricktalmadge/bootstrapper — pull request #46 by Anahkiasen (2012-09-10 13:36:22+00:00)
Title: Add Tables::close and Tables::display to Tables class - Closes #41

This is a first stub of a `Tables::display()` function for quick displaying of Models and arrays.
It also adds a `Tables::close()` function.
Syntax is the following :

```php
{{ Tables::bordered_striped_hover() }}
{{ Tables::headers(array('name', 'comments', 'client')) }}
{{ Tables::display(
$projects,
array('id', 'created_at', 'updated_at'),
array(
'edit' => HTML::link_to_action('projects@update', 'Edit', array('(:id)')),
'delete' => HTML::link_to_action('projects@delete', 'Delete', array('(:id)')),
)) }}
{{ Tables::close() }}
```

`Tables::close()` is pretty straightforward as it simply prints a `

` tag.
Now `Tables::display works like this :
```php
/**
* Displays an array of data
*
* @param mixed $rows Can be an array of data or models
* @param array $ignore An array of columns to ignore
* @param array $supplementary An array of supplementary columns to append
* @return string A table body
*/
public static function display($rows, $ignore = array(), $supplementary = array())
```
* `$rows` can be either an array of data, simple ; or the results from, say, a `Model::all()` or any query that returns an array of Models with an `attributes` method.
* `$ignore` is an array of keys to ignore in each row of the data
* `$supplementary` is an array of supplementary columns to append, in the form CLASS => CONTENT ; CLASS is a class `column-something` that will be set on the	to let the function still allow customization. And value is just value, can be anything. Text, a link, anything. The little cherry on top is that it accepts Laravel patterns, in the form of, say, `(:id)`. So if like in the example above you do a link with (:id) or (:name), it will replace said pattern with said value in the row's array. ie. it will replace `(:id)` with `$project['id']` or if it's a model, `(:name)` with `$project->name`. This allows the creation of custom links for different actions.

This is all a first stub of the function, so I'm awaiting your comments on changes or ways to make it better/easier to use.