nestive_rendering 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 099ff10f13d97d6e59b72959b44445ebc9919d52
4
- data.tar.gz: d3c8a453d1c30dfb6131f50ef7e51b7cf5735fde
3
+ metadata.gz: 718534e775cc27b0f914e6b819276fce7dafbe56
4
+ data.tar.gz: c6b5768099cf80e2764e4a09878918a93117628d
5
5
  SHA512:
6
- metadata.gz: 463152fc1c35aac30f7d01b57495ce50315d5a0394056563c7799c31022353da41445a38bed1fc04e0489a3a8ce6755c6537691fa50bde160cecaefe0e5883b7
7
- data.tar.gz: ed95fd4b280fecbd6721834bb2340f2c3db1dd8446a2b73fcd2fe464fdd0e69abefc4a15cc504f036b27388ec6b28e03c2a07bc2c37e1d5886f8349e7da89032
6
+ metadata.gz: 640c89dd1a849726813a2ce130e00de66ff922dbedbd83e5d27d2a3fd7be1bc7ce1baa9908a9c3b1b6c9a153243dbcf13d181f1b75c49a866bee9b9fde493755
7
+ data.tar.gz: 88e85dfd59fcb844dd63741ef96ae39cf7cd7786739e4909b9681f2b3f3abec5143b9c39cdff3d8303a4ee04dc8d559412890117d160b723d573cdceb556dc17
@@ -142,7 +142,7 @@ module NestiveRendering
142
142
  # @param [String] content
143
143
  # An optional String of content to add to the area as you declare it.
144
144
  def area(name, content=nil, &block)
145
- content = capture(&block) if block_given?
145
+ content = -> { capture(&block) } if block_given?
146
146
  append name, content
147
147
  render_area name
148
148
  end
@@ -164,7 +164,7 @@ module NestiveRendering
164
164
  # @param [String] content
165
165
  # Optionally provide a String of content, instead of a block. A block will take precedence.
166
166
  def append(name, content=nil, &block)
167
- content = capture(&block) if block_given?
167
+ content = -> { capture(&block) } if block_given?
168
168
  add_instruction_to_area name, :push, content
169
169
  end
170
170
 
@@ -185,7 +185,7 @@ module NestiveRendering
185
185
  # @param [String] content
186
186
  # Optionally provide a String of content, instead of a block. A block will take precedence.
187
187
  def prepend(name, content=nil, &block)
188
- content = capture(&block) if block_given?
188
+ content = -> { capture(&block) } if block_given?
189
189
  add_instruction_to_area name, :unshift, content
190
190
  end
191
191
 
@@ -206,7 +206,7 @@ module NestiveRendering
206
206
  # @param [String] content
207
207
  # Optionally provide a String of content, instead of a block. A block will take precedence.
208
208
  def replace(name, content=nil, &block)
209
- content = capture(&block) if block_given?
209
+ content = -> { capture(&block) } if block_given?
210
210
  add_instruction_to_area name, :replace, [content]
211
211
  end
212
212
 
@@ -255,6 +255,8 @@ module NestiveRendering
255
255
  @_area_for.fetch(name, []).reverse_each do |method_name, content|
256
256
  output.public_send method_name, content
257
257
  end
258
+ end.map do |content|
259
+ content.respond_to?(:call) ? content.call : content
258
260
  end.join.html_safe
259
261
  end
260
262
 
@@ -1,3 +1,3 @@
1
1
  module NestiveRendering
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -54,6 +54,12 @@ describe NestiveController do
54
54
  get :replace
55
55
  assert_select '#some-area', 'replaced'
56
56
  end
57
+
58
+ it 'does not call the original/replaced area' do
59
+ expect(DummyClass).not_to receive(:content)
60
+ get :replace
61
+ assert_select '#another-area', 'replaced content'
62
+ end
57
63
  end
58
64
 
59
65
  context '#purge' do
@@ -15,3 +15,9 @@ class NestiveController < ApplicationController
15
15
  render layout: 'locals'
16
16
  end
17
17
  end
18
+
19
+ class DummyClass
20
+ def self.content
21
+ 'dummy content'
22
+ end
23
+ end
@@ -10,6 +10,12 @@
10
10
  Some content
11
11
  <%- end -%>
12
12
  </div>
13
+
14
+ <div id="another-area">
15
+ <%= area :area_to_be_replaced do -%>
16
+ <%= DummyClass.content %>
17
+ <%- end -%>
18
+ </div>
13
19
  <div id="empty-area"><%= area :empty_area %></div>
14
20
  </body>
15
21
  </html>
@@ -4,4 +4,9 @@
4
4
 
5
5
  <%= replace :some_area do %>
6
6
  replaced
7
- <% end %>
7
+ <% end %>
8
+
9
+ <%= replace :area_to_be_replaced do %>
10
+ replaced content
11
+ <% end %>
12
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nestive_rendering
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin French
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-08 00:00:00.000000000 Z
13
+ date: 2015-07-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -66,7 +66,6 @@ files:
66
66
  - spec/internal/app/views/nestive/purge_single.html.erb
67
67
  - spec/internal/app/views/nestive/replace.html.erb
68
68
  - spec/internal/config/routes.rb
69
- - spec/internal/log/test.log
70
69
  - spec/spec_helper.rb
71
70
  homepage: https://github.com/mdeering/nestive_rendering
72
71
  licenses:
@@ -88,35 +87,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
87
  version: '0'
89
88
  requirements: []
90
89
  rubyforge_project:
91
- rubygems_version: 2.4.2
90
+ rubygems_version: 2.4.7
92
91
  signing_key:
93
92
  specification_version: 4
94
93
  summary: A Rails gem for awesome nested templates, layouts and paritals
95
94
  test_files:
96
- - spec/spec_helper.rb
97
- - spec/controllers/nestive_spec.rb
98
95
  - spec/internal/config/routes.rb
99
- - spec/internal/app/controllers/nestive_controller.rb
100
- - spec/internal/app/controllers/application_controller.rb
101
96
  - spec/internal/app/views/nestive/_features.html.erb
102
- - spec/internal/app/views/nestive/extended_partial_options.html.haml
97
+ - spec/internal/app/views/nestive/purge_single.html.erb
98
+ - spec/internal/app/views/nestive/extended_two.html.erb
99
+ - spec/internal/app/views/nestive/prepend.html.erb
103
100
  - spec/internal/app/views/nestive/replace.html.erb
104
- - spec/internal/app/views/nestive/extended_one.html.erb
101
+ - spec/internal/app/views/nestive/locals.html.erb
105
102
  - spec/internal/app/views/nestive/_features_options.html.erb
106
- - spec/internal/app/views/nestive/extended_partial.html.erb
103
+ - spec/internal/app/views/nestive/extended_one.html.erb
107
104
  - spec/internal/app/views/nestive/extended_three.html.erb
108
- - spec/internal/app/views/nestive/_extended_features_options.html.haml
109
- - spec/internal/app/views/nestive/prepend.html.erb
110
- - spec/internal/app/views/nestive/index.html.erb
111
- - spec/internal/app/views/nestive/purge_single.html.erb
112
- - spec/internal/app/views/nestive/locals.html.erb
105
+ - spec/internal/app/views/nestive/extended_partial.html.erb
113
106
  - spec/internal/app/views/nestive/purge_multiple.html.erb
107
+ - spec/internal/app/views/nestive/index.html.erb
114
108
  - spec/internal/app/views/nestive/_extended_features.html.erb
115
- - spec/internal/app/views/nestive/extended_two.html.erb
116
109
  - spec/internal/app/views/nestive/append.html.erb
110
+ - spec/internal/app/views/nestive/extended_partial_options.html.haml
111
+ - spec/internal/app/views/nestive/_extended_features_options.html.haml
117
112
  - spec/internal/app/views/layouts/nestive.html.erb
113
+ - spec/internal/app/views/layouts/extend_two.html.erb
118
114
  - spec/internal/app/views/layouts/needs_options.html.erb
119
115
  - spec/internal/app/views/layouts/locals.html.erb
120
116
  - spec/internal/app/views/layouts/extend_one.html.erb
121
- - spec/internal/app/views/layouts/extend_two.html.erb
122
- - spec/internal/log/test.log
117
+ - spec/internal/app/controllers/application_controller.rb
118
+ - spec/internal/app/controllers/nestive_controller.rb
119
+ - spec/controllers/nestive_spec.rb
120
+ - spec/spec_helper.rb
@@ -1,43 +0,0 @@
1
- Processing by NestiveController#index as HTML
2
- Rendered nestive/index.html.erb within layouts/nestive (0.6ms)
3
- Completed 200 OK in 3.6ms (Views: 3.5ms)
4
- Processing by NestiveController#index as HTML
5
- Completed 200 OK in 0.3ms (Views: 0.2ms)
6
- Processing by NestiveController#index as HTML
7
- Completed 200 OK in 0.2ms (Views: 0.2ms)
8
- Processing by NestiveController#append as HTML
9
- Completed 200 OK in 0.8ms (Views: 0.7ms)
10
- Processing by NestiveController#append as HTML
11
- Completed 200 OK in 0.3ms (Views: 0.2ms)
12
- Processing by NestiveController#prepend as HTML
13
- Completed 200 OK in 0.7ms (Views: 0.6ms)
14
- Processing by NestiveController#prepend as HTML
15
- Completed 200 OK in 0.2ms (Views: 0.2ms)
16
- Processing by NestiveController#replace as HTML
17
- Completed 200 OK in 0.8ms (Views: 0.7ms)
18
- Processing by NestiveController#replace as HTML
19
- Completed 200 OK in 0.2ms (Views: 0.2ms)
20
- Processing by NestiveController#purge_single as HTML
21
- Completed 200 OK in 0.7ms (Views: 0.6ms)
22
- Processing by NestiveController#purge_multiple as HTML
23
- Completed 200 OK in 0.9ms (Views: 0.7ms)
24
- Processing by NestiveController#extended_one as HTML
25
- Completed 200 OK in 1.2ms (Views: 1.1ms)
26
- Processing by NestiveController#extended_two as HTML
27
- Completed 200 OK in 1.2ms (Views: 1.1ms)
28
- Processing by NestiveController#extended_three as HTML
29
- Completed 200 OK in 1.1ms (Views: 0.9ms)
30
- Processing by NestiveController#locals as HTML
31
- Completed 200 OK in 1.7ms (Views: 1.6ms)
32
- Processing by NestiveController#extended_partial as HTML
33
- Rendered nestive/_features.html.erb (0.3ms)
34
- Rendered nestive/_extended_features.html.erb (1.0ms)
35
- Completed 200 OK in 3.1ms (Views: 3.0ms)
36
- Processing by NestiveController#extended_partial_options as HTML
37
- Rendered nestive/_features_options.html.erb (0.4ms)
38
- Rendered nestive/_extended_features_options.html.haml (1.5ms)
39
- Completed 200 OK in 3.0ms (Views: 2.9ms)
40
- Processing by NestiveController#extended_partial_options as HTML
41
- Rendered nestive/_features_options.html.erb (0.1ms)
42
- Rendered nestive/_extended_features_options.html.haml (0.3ms)
43
- Completed 200 OK in 0.7ms (Views: 0.7ms)