blocks 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/views/blocks/_table.html.erb +1 -1
- data/lib/blocks/context.rb +13 -16
- metadata +3 -3
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<%= table.define :data_columns do |options| %>
|
58
58
|
<% table.columns.each do |column| %>
|
59
|
-
<%= content_tag :td, options.merge(column.options)[:
|
59
|
+
<%= content_tag :td, options.merge(column.options)[:column_html] do %>
|
60
60
|
<%= table.use column, options.merge(:column => column) %>
|
61
61
|
<% end %>
|
62
62
|
<% end %>
|
data/lib/blocks/context.rb
CHANGED
@@ -8,7 +8,7 @@ module Blocks
|
|
8
8
|
def method_missing(m, options={}, &block)
|
9
9
|
# If the specified block group has already been defined, it is simply returned here for iteration.
|
10
10
|
# It will consist of all the blocks used in this block group that have yet to be rendered,
|
11
|
-
# as the call for their use occurred before the template was rendered
|
11
|
+
# as the call for their use occurred before the template was rendered (where their definitions likely occurred)
|
12
12
|
return self.block_groups[m] unless self.block_groups[m].nil?
|
13
13
|
|
14
14
|
# Allows for nested block groups, store the current block positions array and start a new one
|
@@ -65,6 +65,7 @@ module Blocks
|
|
65
65
|
block_container.block = block
|
66
66
|
|
67
67
|
blocks[name.to_sym] = block_container if blocks[name.to_sym].nil?
|
68
|
+
|
68
69
|
nil
|
69
70
|
end
|
70
71
|
|
@@ -88,6 +89,8 @@ module Blocks
|
|
88
89
|
# Delays rendering this block until the partial has been rendered and all the blocks have had a chance to be defined
|
89
90
|
self.block_positions << block_container
|
90
91
|
end
|
92
|
+
|
93
|
+
nil
|
91
94
|
end
|
92
95
|
|
93
96
|
def render
|
@@ -133,61 +136,55 @@ module Blocks
|
|
133
136
|
name = name_or_container.to_sym
|
134
137
|
end
|
135
138
|
|
136
|
-
|
139
|
+
view.concat(render_before_blocks(name, options))
|
137
140
|
|
138
141
|
if blocks[name]
|
139
142
|
block_container = blocks[name]
|
140
|
-
|
143
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(render_options), &block_container.block)
|
141
144
|
elsif view.blocks.blocks[name]
|
142
145
|
block_container = view.blocks.blocks[name]
|
143
|
-
|
146
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(render_options), &block_container.block)
|
144
147
|
else
|
145
148
|
begin
|
146
|
-
|
149
|
+
view.concat(view.render "#{shared_options[:templates_folder]}/#{name.to_s}", shared_options.merge(render_options))
|
147
150
|
rescue
|
148
151
|
|
149
152
|
end
|
150
153
|
end
|
151
154
|
|
152
|
-
|
155
|
+
view.concat(render_after_blocks(name, options))
|
153
156
|
end
|
154
157
|
|
155
158
|
def render_before_blocks(name, options={})
|
156
159
|
name = "before_#{name.to_s}".to_sym
|
157
160
|
|
158
|
-
ret = ActionView::NonConcattingString.new
|
159
161
|
unless blocks[name].nil?
|
160
162
|
blocks[name].each do |block_container|
|
161
|
-
|
163
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(options), &block_container.block)
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
165
167
|
unless view.blocks.blocks[name].nil?
|
166
168
|
view.blocks.blocks[name].each do |block_container|
|
167
|
-
|
169
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(options), &block_container.block)
|
168
170
|
end
|
169
171
|
end
|
170
|
-
|
171
|
-
ret
|
172
172
|
end
|
173
173
|
|
174
174
|
def render_after_blocks(name, options={})
|
175
175
|
name = "after_#{name.to_s}".to_sym
|
176
176
|
|
177
|
-
ret = ActionView::NonConcattingString.new
|
178
177
|
unless blocks[name].nil?
|
179
178
|
blocks[name].each do |block_container|
|
180
|
-
|
179
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(options), &block_container.block)
|
181
180
|
end
|
182
181
|
end
|
183
182
|
|
184
183
|
unless view.blocks.blocks[name].nil?
|
185
184
|
view.blocks.blocks[name].each do |block_container|
|
186
|
-
|
185
|
+
view.concat(view.capture shared_options.merge(block_container.options).merge(options), &block_container.block)
|
187
186
|
end
|
188
187
|
end
|
189
|
-
|
190
|
-
ret
|
191
188
|
end
|
192
189
|
end
|
193
190
|
end
|
metadata
CHANGED