markevans-block_helpers 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -47,6 +47,12 @@ This will generate the following:
47
47
  <p>Hi there Marmaduke!</p>
48
48
  ...hooray!
49
49
 
50
+
51
+ Accessing other helper methods
52
+ ------------------------------
53
+
54
+ Methods available in the parent helper are available to the block helper class via the protected object `helper` (see use of `content_tag` below).
55
+
50
56
  Using arguments
51
57
  ---------------
52
58
 
@@ -62,7 +68,7 @@ In the helper:
62
68
  end
63
69
 
64
70
  def hello(name)
65
- content_tag @tag_type, "Hi there #{name}!"
71
+ helper.content_tag @tag_type, "Hi there #{name}!"
66
72
  end
67
73
 
68
74
  end
@@ -78,20 +84,18 @@ In the view:
78
84
  This generates:
79
85
 
80
86
  <span>Hi there Marmaduke!</span>
81
-
82
- Note that methods available in the helper (e.g. `content_tag`) are also available in the block helper class.
83
87
 
84
88
  Surrounding markup
85
89
  ------------------
86
90
 
87
- Use the `to_s` method to surround the block with markup, e.g.
91
+ Use the `render` method to surround the block with markup, e.g.
88
92
  In the helper:
89
93
 
90
94
  module MyHelper
91
95
 
92
96
  class RoundedBox < ActionView::BlockHelper
93
97
 
94
- def to_s(body)
98
+ def render(body)
95
99
  %(
96
100
  <div class="tl">
97
101
  <div class="tr">
@@ -127,6 +131,7 @@ This generates:
127
131
  </div>
128
132
  </div>
129
133
 
134
+ Of course, you could use `render` for more than just surrounding markup.
130
135
 
131
136
  Installation
132
137
  ============
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{block_helpers}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mark Evans"]
9
- s.date = %q{2009-08-12}
9
+ s.date = %q{2009-08-13}
10
10
  s.email = %q{mark@new-bamboo.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
data/lib/block_helpers.rb CHANGED
@@ -18,8 +18,8 @@ module ActionView
18
18
  klass.parent.class_eval %(
19
19
  def #{method_name}(*args, &block)
20
20
  renderer = #{klass.name}.new(*args)
21
- if renderer.public_methods(false).include? 'to_s'
22
- concat renderer.to_s(capture(renderer, &block))
21
+ if renderer.public_methods(false).include? 'render'
22
+ concat renderer.render(capture(renderer, &block))
23
23
  else
24
24
  block.call(renderer)
25
25
  end
@@ -65,7 +65,7 @@ describe TestHelperModule do
65
65
 
66
66
  before(:each) do
67
67
  class TestHelperModule::TestHelperSurround < ActionView::BlockHelper
68
- def to_s(body)
68
+ def render(body)
69
69
  %(
70
70
  <p>Before</p>
71
71
  #{body}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markevans-block_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Evans
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -07:00
12
+ date: 2009-08-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency