blocks 0.11 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +40 -4
  2. data/lib/blocks/builder.rb +2 -2
  3. metadata +5 -4
data/README.rdoc CHANGED
@@ -114,9 +114,45 @@ What's particularly useful about this is that it doesn't matter if the "before"
114
114
  table_for is a useful example of using blocks in a very practical way. It is built entirely using the core blocks library. It is exposed as a helper method with the following prototype:
115
115
 
116
116
  table_for(records, options={}, &block)
117
-
118
- The first argument, "records", is the list of objects to render rows in the table for, "options" allows you to specify table-wide settings, and the "block" allows you to specify the
119
-
117
+
118
+ For example, if you have an Array of objects that respond to the following [:name, :email, :phonenumber] e.g.
119
+
120
+ @records = [OpenStruct.new({:name => "The Name", :email => "The Email", :phonenumber => "A phone number"}),
121
+ OpenStruct.new({:name => "The Second Name", :email => "The Second Email", :phonenumber => "A second phone number"})]
122
+
123
+ And using table_for you define each column with the following:
124
+
125
+ <%= table_for @records do |table| %>
126
+ <%= table.column :name %>
127
+ <%= table.column :email %>
128
+ <%= table.column :phonenumber %>
129
+ <% end %>
130
+
131
+ Will generate the following table:
132
+
133
+ <table>
134
+ <thead>
135
+ <tr>
136
+ <th>Name</th>
137
+ <th>Email</th>
138
+ <th>Phonenumber</th>
139
+ </tr>
140
+ </thead>
141
+ <tbody>
142
+ <tr class="odd">
143
+ <td>The Name</td>
144
+ <td>The Email</td>
145
+ <td>A phone number</td>
146
+ </tr>
147
+ <tr class="even">
148
+ <td>The Second Name</td>
149
+ <td>The Second Email</td>
150
+ <td>A second phone number</td>
151
+ </tr>
152
+ </tbody>
153
+ </table>
154
+
155
+
120
156
  == Special Thanks
121
157
 
122
- Thanks to Todd Fisher of Captico for implementation help and setup of gem and to Jon Phillips for suggestions and use case help.
158
+ Thanks to Todd Fisher of Captico for implementation help and setup of gem and to Jon Phillips for suggestions and use case help.
@@ -164,8 +164,8 @@ module Blocks
164
164
  else
165
165
  begin
166
166
  view.concat(view.render "#{shared_options[:templates_folder]}/#{name.to_s}", shared_options.merge(render_options))
167
- rescue
168
- puts "Could not render template #{name} in directory #{shared_options[:templates_folder]}"
167
+ rescue ActionView::MissingTemplate
168
+ # This block does not exist and no partial can be found to satify it
169
169
  end
170
170
  end
171
171
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 11
9
- version: "0.11"
9
+ - 0
10
+ version: 1.0.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Andrew Hunter
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-12-22 00:00:00 -05:00
19
+ date: 2011-01-07 00:00:00 -05:00
19
20
  default_executable:
20
21
  dependencies: []
21
22