table-for 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +63 -0
- data/VERSION +1 -1
- metadata +17 -15
data/README.rdoc
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
= table-for
|
2
|
+
|
3
|
+
Table-for is a table builder for a collection of domain objects. It very easily allows the user to specify the columns to render and to override how the table, the header columns, the rows, and the columns are rendered.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
In <b>Rails 3</b>, add this to your Gemfile.
|
8
|
+
|
9
|
+
gem "table-for"
|
10
|
+
|
11
|
+
== Sample Usage
|
12
|
+
|
13
|
+
Say we have fetched a collection of users from the database (stored as @users), in the view we can generate a very unique table with just a few lines of code:
|
14
|
+
|
15
|
+
<%= table_for @users,
|
16
|
+
:table_html => {:id => "users"},
|
17
|
+
:header_html => {:style => "color:red"},
|
18
|
+
:row_html => {:class => lambda { |parameters| cycle('odd', 'even')}},
|
19
|
+
:column_html => {:style => "color:green"} do |table| %>
|
20
|
+
<%= table.column :name, :column_html => {:style => "color:blue"}, :header_html => {:style => "color:orange"} %>
|
21
|
+
<%= table.column :email %>
|
22
|
+
<%= table.column :phonenumber, :column_html => {:style => "color:orange"}, :header_html => {:style => "color:blue"} do |user| %>
|
23
|
+
<%= phonenumber(user.phonenumber) %>
|
24
|
+
<% end %>
|
25
|
+
<%= table.column :label => "???" do |user| %>
|
26
|
+
Some Random Column
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
Will generate the following table:
|
31
|
+
<table id="users">
|
32
|
+
<thead>
|
33
|
+
<tr>
|
34
|
+
<th style="color:orange">Name</th>
|
35
|
+
<th style="color:red">Email</th>
|
36
|
+
<th style="color:blue">Phonenumber</th>
|
37
|
+
<th style="color:red">???</th>
|
38
|
+
</tr>
|
39
|
+
</thead>
|
40
|
+
<tbody>
|
41
|
+
<tr class="odd">
|
42
|
+
<td style="color:blue">USER 1'S NAME</td>
|
43
|
+
<td style="color:green">USER 1'S EMAIL</td>
|
44
|
+
<td style="color:orange">USER 1'S PHONENUMBER</td>
|
45
|
+
<td style="color:green">Some Random Column</td>
|
46
|
+
</tr>
|
47
|
+
<tr class="even">
|
48
|
+
<td style="color:blue">USER 2'S NAME</td>
|
49
|
+
<td style="color:green">USER 2'S </td>
|
50
|
+
<td style="color:orange">USER 2'S PHONENUMBER</td>
|
51
|
+
<td style="color:green">Some Random Column</td>
|
52
|
+
</tr>
|
53
|
+
...
|
54
|
+
<tr class="odd">
|
55
|
+
<td style="color:blue">LAST USER'S NAME</td>
|
56
|
+
<td style="color:green">LAST USER'S EMAIL</td>
|
57
|
+
<td style="color:orange">LAST USER'S PHONENUMBER</td>
|
58
|
+
<td style="color:green">Some Random Column</td>
|
59
|
+
</tr>
|
60
|
+
</tbody>
|
61
|
+
</table>
|
62
|
+
|
63
|
+
Notice in the above example, we were able to provide the default attributes to be applied to each column, header, and row. Then, when specifying which columns to render, the column and header attributes could be overridden on a column by column basis.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table-for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 63
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 16
|
10
|
+
version: 0.0.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Hunter
|
@@ -15,12 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-20 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
prerelease: false
|
23
|
-
type: :runtime
|
24
22
|
name: table-for
|
25
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
24
|
none: false
|
@@ -31,10 +29,10 @@ dependencies:
|
|
31
29
|
segments:
|
32
30
|
- 0
|
33
31
|
version: "0"
|
34
|
-
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
32
|
prerelease: false
|
37
33
|
type: :runtime
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
38
36
|
name: rails
|
39
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
38
|
none: false
|
@@ -47,20 +45,24 @@ dependencies:
|
|
47
45
|
- 0
|
48
46
|
- 0
|
49
47
|
version: 3.0.0
|
50
|
-
requirement: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
48
|
prerelease: false
|
53
49
|
type: :runtime
|
50
|
+
requirement: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
54
52
|
name: building-blocks
|
55
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
54
|
none: false
|
57
55
|
requirements:
|
58
|
-
- - "
|
56
|
+
- - "="
|
59
57
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
58
|
+
hash: 17
|
61
59
|
segments:
|
62
60
|
- 0
|
63
|
-
|
61
|
+
- 0
|
62
|
+
- 7
|
63
|
+
version: 0.0.7
|
64
|
+
prerelease: false
|
65
|
+
type: :runtime
|
64
66
|
requirement: *id003
|
65
67
|
description: table-for is a table builder for an array of objects, easily allowing overriding of how any aspect of the table is generated
|
66
68
|
email: hunterae@gmail.com
|
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
112
|
requirements: []
|
111
113
|
|
112
114
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.
|
115
|
+
rubygems_version: 1.5.2
|
114
116
|
signing_key:
|
115
117
|
specification_version: 3
|
116
118
|
summary: table-for is a table builder for an array of objects, easily allowing overriding of how any aspect of the table is generated
|