blocks 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,14 +4,12 @@ module Blocks
4
4
  options = {}
5
5
  options[:view] = self
6
6
 
7
- @blocks ||= Blocks::Context.new(options)
7
+ @blocks ||= Blocks::Builder.new(options)
8
8
  end
9
9
 
10
- def evaluated_content_options(options={})
11
- puts "Checking evaluated_content_options #{options.inspect}"
12
-
10
+ def evaluated_content_options(options={}, parameters={})
13
11
  evaluated_options = {}
14
- options.each_pair { |k, v| evaluated_options[k] = (v.is_a?(Proc) ? v.call(options) : v)}
12
+ options.each_pair { |k, v| evaluated_options[k] = (v.is_a?(Proc) ? v.call(parameters) : v)}
15
13
  evaluated_options
16
14
  end
17
15
 
@@ -19,7 +17,7 @@ module Blocks
19
17
  options[:view] = self
20
18
  options[:records] = records
21
19
  options[:block] = block
22
- options[:row_html] = {:class => lambda { cycle('odd', 'even')}} if options[:row_html].nil?
20
+ options[:row_html] = {:class => lambda { |parameters| cycle('odd', 'even')}} if options[:row_html].nil?
23
21
 
24
22
  Blocks::TableFor.new(options).render
25
23
  end
@@ -49,7 +49,7 @@
49
49
  <% end %>
50
50
 
51
51
  <%= table.define :row do |options| %>
52
- <%= content_tag :tr, evaluated_content_options(options[:row_html].merge({:record => options[:record]})) do %>
52
+ <%= content_tag :tr, evaluated_content_options(options[:row_html], options) do %>
53
53
  <%= table.use :data_columns, options %>
54
54
  <% end %>
55
55
  <% end %>
@@ -1,5 +1,5 @@
1
1
  require 'blocks/container'
2
- require 'blocks/context'
2
+ require 'blocks/builder'
3
3
  require 'blocks/table_for'
4
4
  require 'blocks/list_for'
5
5
  require 'blocks/engine'
@@ -1,5 +1,5 @@
1
1
  module Blocks
2
- class Context
2
+ class Builder
3
3
 
4
4
  attr_accessor :view, :blocks, :block_positions, :anonymous_block_number,
5
5
  :start_rendering_blocks, :block_groups, :shared_options
@@ -148,7 +148,7 @@ module Blocks
148
148
  begin
149
149
  view.concat(view.render "#{shared_options[:templates_folder]}/#{name.to_s}", shared_options.merge(render_options))
150
150
  rescue
151
-
151
+ puts "Could not render template #{name} in directory #{shared_options[:templates_folder]}"
152
152
  end
153
153
  end
154
154
 
@@ -1,5 +1,5 @@
1
1
  module Blocks
2
- class ListFor < Blocks::Context
2
+ class ListFor < Blocks::Builder
3
3
  alias items block_positions
4
4
  alias item use
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Blocks
2
- class TableFor < Blocks::Context
2
+ class TableFor < Blocks::Builder
3
3
  alias columns block_positions
4
4
  alias column use
5
5
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 6
9
- version: "0.6"
8
+ - 7
9
+ version: "0.7"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Hunter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-08 00:00:00 -05:00
18
+ date: 2010-12-10 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -29,8 +29,8 @@ extra_rdoc_files:
29
29
  - LICENSE
30
30
  - README
31
31
  files:
32
+ - lib/blocks/builder.rb
32
33
  - lib/blocks/container.rb
33
- - lib/blocks/context.rb
34
34
  - lib/blocks/engine.rb
35
35
  - lib/blocks/list_for.rb
36
36
  - lib/blocks/table_for.rb