nestive-rails 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: e778a2d47f320ad068588c3f44c490180ac6c4b11f798fc75221d9d90d062f4a
4
- data.tar.gz: 61bdc1cbc98b08835b346ea28cf503749ea4815611fec54b31cbc6cf41068f58
3
+ metadata.gz: eb88c789b7e51155d7160366f7f589eac5fa473a4a7b42be7293af40f75f2c13
4
+ data.tar.gz: 33b41325df206030f5167b30efe18eff98c767b0a64ecb98dc8c61b419851356
5
5
  SHA512:
6
- metadata.gz: 31721d6e189247ae917be96041c83f52493e8f1d33206f896a0ab263071ac615dd913dd5293142d02f6002428e6e7f7b16612bca216feabddf7741d78551ca7f
7
- data.tar.gz: b489b97f12348180d2093e33a15b2421ca41cf586a949458924e6c7a4a8501f0dfacd1d1cbbd9bad97781c4c66d27f83270511a2fbda889774631efae24b4e58
6
+ metadata.gz: 0d8e267cc820094dd88b7b1c6a828e441aae4772b6cf3fa95e734196d9c04ae9d4183e0c6339fddd5286d5ede26d3f460eb7d0f0cbc98b2b4d0dfbfc76c44252
7
+ data.tar.gz: dcfac54b385a4f76d763d74b7e0198248abb79fa11f1f55a5f75a0b5628f2dc93968e09d918ae82e2a23f1dd707775eb0f2b5db1005888d0e1b71f06fb48a815
@@ -1,14 +1,13 @@
1
- # Changelog
2
-
3
- ### master
4
-
5
- * nothing yet
6
-
7
- ### 1.0.1 - 2018-01-06
8
-
9
- * enhancements
10
- * cleaning up gem files
11
-
12
- ### 1.0.0 - 2017-12-19
13
-
14
- * initial release
1
+ # Changelog
2
+
3
+ This file tracks all unreleased breaking changes and deprecations on `master`. You can find a list of all releases [here](https://github.com/jonhue/nestive-rails/releases).
4
+
5
+ nestive-rails follows Semantic Versioning 2.0 as defined at http://semver.org.
6
+
7
+ ### Breaking Changes
8
+
9
+ * None
10
+
11
+ ### Deprecated
12
+
13
+ * None
data/LICENSE CHANGED
@@ -1,21 +1,42 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Jonas Hübotter
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Jonas Hübotter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Copyright (c) 2011 Justin French
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining
26
+ a copy of this software and associated documentation files (the
27
+ "Software"), to deal in the Software without restriction, including
28
+ without limitation the rights to use, copy, modify, merge, publish,
29
+ distribute, sublicense, and/or sell copies of the Software, and to
30
+ permit persons to whom the Software is furnished to do so, subject to
31
+ the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be
34
+ included in all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
40
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
41
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
42
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,317 +1,311 @@
1
- # nestive-rails
2
-
3
- [![Gem Version](https://badge.fury.io/rb/nestive-rails.svg)](https://badge.fury.io/rb/nestive-rails) <img src="https://travis-ci.org/jonhue/nestive-rails.svg?branch=master" />
4
-
5
- This gem is a continuation for Rails 5 of the [nestive](https://github.com/rwz/nestive) gem originally created by Justin French and Pavel Pravosud.
6
-
7
- nestive-rails adds powerful layout and view helpers to your Rails app. It's similar to the nested layout technique [already documented in the Rails guides](http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts) and found in many other nested layout plugins (a technique using `content_for` and rendering the parent layout at the end of the child layout). There's a bunch of problems with this technique, including:
8
-
9
- * you can only *append* content to the content buffer with `content_for` (you can't prepend to content, you can't replace it)
10
- * when combined with this nested layout technique, `content_for` actually *prepends* new content to the buffer, because each parent layout is rendered *after* it's child
11
-
12
- nestive-rails is *better* because it addresses these problems.
13
-
14
- ---
15
-
16
- ## Table of Contents
17
-
18
- * [Installation](#installation)
19
- * [Usage](#usage)
20
- * [Declaring an area of content with `area`](#declaring-an-area-of-content-with-area)
21
- * [Appending content to an area with `append`](#appending-content-to-an-area-with-append)
22
- * [Prepending content to an area with `prepend`](#prepending-content-to-an-area-with-prepend)
23
- * [Replacing content with `replace`](#replacing-content-with-replace)
24
- * [Removing content with `purge`](#removing-content-with-purge)
25
- * [Extending a layout in a child layout (or view) with `extends`](#extending-a-layout-in-a-child-layout-or-view-with-extends)
26
- * [Example](#example)
27
- * [Caching](#caching)
28
- * [To Do](#to-do)
29
- * [Contributing](#contributing)
30
- * [Contributors](#contributors)
31
- * [License](#license)
32
-
33
- ---
34
-
35
- ## Installation
36
-
37
- `nestive-rails` works with Rails 5.0 onwards. You can add it to your `Gemfile` with:
38
-
39
- ```ruby
40
- gem 'nestive-rails'
41
- ```
42
-
43
- And then execute:
44
-
45
- $ bundle
46
-
47
- Or install it yourself as:
48
-
49
- $ gem install nestive-rails
50
-
51
- If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
52
-
53
- ```ruby
54
- gem 'nestive-rails', github: 'jonhue/nestive-rails'
55
- ```
56
-
57
- ## Usage
58
-
59
- ### Declaring an area of content with `area`
60
-
61
- The `area` helper is a lot like Rails' own `<%= yield :foo %>`, and is used in layouts to define and render a chunk of content in your layout:
62
-
63
- ```erb
64
- <%= area :sidebar %>
65
- ```
66
-
67
- Unlike `yield`, `area` will allow your parent layouts to add content to the area at the same time using either a String or a block:
68
-
69
- ```erb
70
- <%= area :sidebar, "Some Content Here" %>
71
-
72
- <%= area :sidebar do %>
73
- Some Content Here
74
- <% end %>
75
- ```
76
-
77
- It's important to note that this isn't *default* content, it *is* the content (unless a child changes it).
78
-
79
- ### Appending content to an area with `append`
80
-
81
- The implementation details are quite different, but the `append` helper works much like Rails' built-in `content_for`. It will work with either a String or block, adding the new content onto the end of any content previously provided by parent layouts:
82
-
83
- ```erb
84
- <%= extends :application do %>
85
- <% append :sidebar, "More content." %>
86
- <% append :sidebar do %>
87
- More content.
88
- <% end %>
89
- <% end %>
90
- ```
91
-
92
- ### Prepending content to an area with `prepend`
93
-
94
- Exactly what you think it is. The reverse of `append` (duh), adding the new content at the start of any content previously provided by parent layouts:
95
-
96
- ``` erb
97
- <%= extends :application do %>
98
- <%= prepend :sidebar, "Content." %>
99
- <%= prepend :sidebar do %>
100
- Content.
101
- <% end %>
102
- <% end %>
103
- ```
104
-
105
- ### Replacing content with `replace`
106
-
107
- You can also replace any content provided by parent layouts:
108
-
109
- ``` erb
110
- <%= extends :application do %>
111
- <%= replace :sidebar, "New content." %>
112
- <%= replace :sidebar do %>
113
- New content.
114
- <% end %>
115
- <% end %>
116
- ```
117
-
118
- ### Removing content with `purge`
119
-
120
- You can remove the content in the single or in multiple areas
121
-
122
- ``` erb
123
- <% purge :sidebar %>
124
- <% purge :sidebar, :banner %>
125
- ```
126
-
127
- ... which is equal to:
128
-
129
- ``` erb
130
- <% replace :sidebar, nil %>
131
- ```
132
-
133
- ### Extending a layout in a child layout (or view) with `extends`
134
-
135
- Any layout (or view) can declare that it wants to inherit from and extend a parent layout, in this case we're extending `app/views/layouts/application.html.erb`:
136
-
137
- ``` erb
138
- <%= extends :application do %>
139
- ...
140
- <% end %>
141
- ```
142
-
143
- You can nest many levels deep:
144
-
145
- `app/views/layouts/application.html.erb`:
146
-
147
- ``` erb
148
- <!DOCTYPE html>
149
- <html>
150
- <head>
151
- <%= area :head do %>
152
- <title><%= area :title, 'Nestive' %></title>
153
- <% end %>
154
- </head>
155
- <body>
156
- <%= yield %>
157
- </body>
158
- </html>
159
- ```
160
-
161
- `app/views/layouts/with_sidebar.html.erb`:
162
-
163
- ``` erb
164
- <%= extends :application do %>
165
- <div class="sidebar"><%= area(:sidebar) do %>
166
- here goes sidebar
167
- <% end %></div>
168
- <%= yield -%>
169
- <% end %>
170
- ```
171
-
172
- `app/views/layouts/blog_posts.html.erb`:
173
-
174
- ``` erb
175
- <%= extends :with_sidebar do %>
176
- <% append :sidebar do %>
177
- Blog archive:
178
- <%= render_blog_archive %>
179
- <% end %>
180
-
181
- <% append :head do %>
182
- <%= javascript_include_tag 'fancy_blog_archive_tag_cloud' %>
183
- <% end %>
184
-
185
- <%= yield %>
186
- <% end %>
187
- ```
188
-
189
- ---
190
-
191
- ## Example
192
-
193
- Set-up a global layout defining some content areas.
194
-
195
- `app/views/layouts/application.html.erb`:
196
-
197
- ``` erb
198
- <!DOCTYPE html>
199
- <html>
200
- <head>
201
- <meta charset="utf-8">
202
- <title><%= area :title, "JustinFrench.com" %></title>
203
- <meta name="description" content="<%= area :description, "This is my website." %>">
204
- <meta name="keywords" content="<%= area :keywords, "justin, french, ruby, design" %>">
205
- </head>
206
- <body>
207
- <div id="wrapper">
208
- <div id="content">
209
- <%= area :content do %>
210
- <p>Default content goes here.</p>
211
- <% end %>
212
- </div>
213
- <div id="sidebar">
214
- <%= area :sidebar do %>
215
- <h2>About Me</h2>
216
- <p>...</p>
217
- <% end %>
218
- </div>
219
- </div>
220
- <%= yield %>
221
- </body>
222
- </html>
223
- ```
224
-
225
- Next, we set-up a `blog` layout that extends `application`, replacing,
226
- appending & prepending content to the areas we defined earlier.
227
-
228
- `app/views/layouts/blog.html.erb`:
229
-
230
- ``` erb
231
- <%= extends :application do %>
232
- <% replace :title, "My Blog " %>
233
- <% replace :description, "Justin French blogs here on Ruby, Rails, Design, Formtastic, etc" %>
234
- <% prepend :keywords, "blog, weblog, design links, ruby links, formtastic release notes, " %>
235
- <%= yield %>
236
- <% end %>
237
- ```
238
-
239
- Now in our blog index view we can use `blog` layout and fill in the areas with
240
- content specific to the index action.
241
-
242
-
243
- `app/views/posts/index.html.erb`:
244
-
245
- ``` erb
246
- <% replace :content do %>
247
- <h1>My Blog</h1>
248
- <%= render @articles %>
249
- <% end %>
250
-
251
- <% append :sidebar do %>
252
- <h2>Blog Roll</h2>
253
- <%= render @links %>
254
- <% end %>
255
- ```
256
-
257
- We also need to instruct the `PostsController` to use this `blog` layout:
258
-
259
- `app/controllers/posts_controller.rb`:
260
-
261
- ``` ruby
262
- class PostsController < ApplicationController
263
- layout 'blog'
264
- end
265
- ```
266
-
267
- ---
268
-
269
- ## Caching
270
-
271
- nestive-rails works the same way `content_for` does and has the same caching drawbacks. That means that nestive-rails helpers are completely ignored when called from within cached block. You probably don't want to use fragment caching around dynamic nestive-rails areas and have to be extra careful what and how you cache to avoid unpleasant surprises.
272
-
273
- ---
274
-
275
- ## To Do
276
-
277
- [Here](https://github.com/jonhue/nestive-rails/projects/1) is the full list of current projects.
278
-
279
- To propose your ideas, initiate the discussion by adding a [new issue](https://github.com/jonhue/nestive-rails/issues/new).
280
-
281
- ---
282
-
283
- ## Contributing
284
-
285
- We hope that you will consider contributing to `nestive-rails`. Please read this short overview for some information about how to get started:
286
-
287
- [Learn more about contributing to this repository](https://github.com/jonhue/nestive-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/nestive-rails/blob/master/CODE_OF_CONDUCT.md)
288
-
289
- ### Contributors
290
-
291
- Give the people some :heart: who are working on this project. See them all at:
292
-
293
- https://github.com/jonhue/nestive-rails/graphs/contributors
294
-
295
- ## License
296
-
297
- MIT License
298
-
299
- Copyright (c) 2017 Jonas Hübotter
300
-
301
- Permission is hereby granted, free of charge, to any person obtaining a copy
302
- of this software and associated documentation files (the "Software"), to deal
303
- in the Software without restriction, including without limitation the rights
304
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
305
- copies of the Software, and to permit persons to whom the Software is
306
- furnished to do so, subject to the following conditions:
307
-
308
- The above copyright notice and this permission notice shall be included in all
309
- copies or substantial portions of the Software.
310
-
311
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
312
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
313
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
314
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
315
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
316
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
317
- SOFTWARE.
1
+ # nestive-rails
2
+
3
+ This gem is a continuation for Rails 5 of the [nestive](https://github.com/rwz/nestive) gem originally created by Justin French and Pavel Pravosud.
4
+
5
+ nestive-rails adds powerful layout and view helpers to your Rails app. It's similar to the nested layout technique [already documented in the Rails guides](http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts) and found in many other nested layout plugins (a technique using `content_for` and rendering the parent layout at the end of the child layout). There's a bunch of problems with this technique, including:
6
+
7
+ * you can only *append* content to the content buffer with `content_for` (you can't prepend to content, you can't replace it)
8
+ * when combined with this nested layout technique, `content_for` actually *prepends* new content to the buffer, because each parent layout is rendered *after* it's child
9
+
10
+ nestive-rails is *better* because it addresses these problems.
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ * [Installation](#installation)
17
+ * [Usage](#usage)
18
+ * [Declaring an area of content with `area`](#declaring-an-area-of-content-with-area)
19
+ * [Appending content to an area with `append`](#appending-content-to-an-area-with-append)
20
+ * [Prepending content to an area with `prepend`](#prepending-content-to-an-area-with-prepend)
21
+ * [Replacing content with `replace`](#replacing-content-with-replace)
22
+ * [Removing content with `purge`](#removing-content-with-purge)
23
+ * [Extending a layout in a child layout (or view) with `extends`](#extending-a-layout-in-a-child-layout-or-view-with-extends)
24
+ * [Example](#example)
25
+ * [Caching](#caching)
26
+ * [Testing](#testing)
27
+ * [Release](#release)
28
+ * [To Do](#to-do)
29
+ * [Contributing](#contributing)
30
+ * [Semantic versioning](#semantic-versioning)
31
+
32
+ ---
33
+
34
+ ## Installation
35
+
36
+ `nestive-rails` works with Rails 5.0 onwards. You can add it to your `Gemfile` with:
37
+
38
+ ```ruby
39
+ gem 'nestive-rails'
40
+ ```
41
+
42
+ And then execute:
43
+
44
+ $ bundle
45
+
46
+ Or install it yourself as:
47
+
48
+ $ gem install nestive-rails
49
+
50
+ If you always want to be up to date fetch the latest from GitHub in your `Gemfile`:
51
+
52
+ ```ruby
53
+ gem 'nestive-rails', github: 'jonhue/nestive-rails'
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ### Declaring an area of content with `area`
59
+
60
+ The `area` helper is a lot like Rails' own `<%= yield :foo %>`, and is used in layouts to define and render a chunk of content in your layout:
61
+
62
+ ```erb
63
+ <%= area :sidebar %>
64
+ ```
65
+
66
+ Unlike `yield`, `area` will allow your parent layouts to add content to the area at the same time using either a String or a block:
67
+
68
+ ```erb
69
+ <%= area :sidebar, "Some Content Here" %>
70
+
71
+ <%= area :sidebar do %>
72
+ Some Content Here
73
+ <% end %>
74
+ ```
75
+
76
+ It's important to note that this isn't *default* content, it *is* the content (unless a child changes it).
77
+
78
+ ### Appending content to an area with `append`
79
+
80
+ The implementation details are quite different, but the `append` helper works much like Rails' built-in `content_for`. It will work with either a String or block, adding the new content onto the end of any content previously provided by parent layouts:
81
+
82
+ ```erb
83
+ <%= extends :application do %>
84
+ <% append :sidebar, "More content." %>
85
+ <% append :sidebar do %>
86
+ More content.
87
+ <% end %>
88
+ <% end %>
89
+ ```
90
+
91
+ ### Prepending content to an area with `prepend`
92
+
93
+ Exactly what you think it is. The reverse of `append` (duh), adding the new content at the start of any content previously provided by parent layouts:
94
+
95
+ ``` erb
96
+ <%= extends :application do %>
97
+ <%= prepend :sidebar, "Content." %>
98
+ <%= prepend :sidebar do %>
99
+ Content.
100
+ <% end %>
101
+ <% end %>
102
+ ```
103
+
104
+ ### Replacing content with `replace`
105
+
106
+ You can also replace any content provided by parent layouts:
107
+
108
+ ``` erb
109
+ <%= extends :application do %>
110
+ <%= replace :sidebar, "New content." %>
111
+ <%= replace :sidebar do %>
112
+ New content.
113
+ <% end %>
114
+ <% end %>
115
+ ```
116
+
117
+ ### Removing content with `purge`
118
+
119
+ You can remove the content in the single or in multiple areas
120
+
121
+ ``` erb
122
+ <% purge :sidebar %>
123
+ <% purge :sidebar, :banner %>
124
+ ```
125
+
126
+ ... which is equal to:
127
+
128
+ ``` erb
129
+ <% replace :sidebar, nil %>
130
+ ```
131
+
132
+ ### Extending a layout in a child layout (or view) with `extends`
133
+
134
+ Any layout (or view) can declare that it wants to inherit from and extend a parent layout, in this case we're extending `app/views/layouts/application.html.erb`:
135
+
136
+ ``` erb
137
+ <%= extends :application do %>
138
+ ...
139
+ <% end %>
140
+ ```
141
+
142
+ You can nest many levels deep:
143
+
144
+ `app/views/layouts/application.html.erb`:
145
+
146
+ ``` erb
147
+ <!DOCTYPE html>
148
+ <html>
149
+ <head>
150
+ <%= area :head do %>
151
+ <title><%= area :title, 'Nestive' %></title>
152
+ <% end %>
153
+ </head>
154
+ <body>
155
+ <%= yield %>
156
+ </body>
157
+ </html>
158
+ ```
159
+
160
+ `app/views/layouts/with_sidebar.html.erb`:
161
+
162
+ ``` erb
163
+ <%= extends :application do %>
164
+ <div class="sidebar"><%= area(:sidebar) do %>
165
+ here goes sidebar
166
+ <% end %></div>
167
+ <%= yield -%>
168
+ <% end %>
169
+ ```
170
+
171
+ `app/views/layouts/blog_posts.html.erb`:
172
+
173
+ ``` erb
174
+ <%= extends :with_sidebar do %>
175
+ <% append :sidebar do %>
176
+ Blog archive:
177
+ <%= render_blog_archive %>
178
+ <% end %>
179
+
180
+ <% append :head do %>
181
+ <%= javascript_include_tag 'fancy_blog_archive_tag_cloud' %>
182
+ <% end %>
183
+
184
+ <%= yield %>
185
+ <% end %>
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Example
191
+
192
+ Set-up a global layout defining some content areas.
193
+
194
+ `app/views/layouts/application.html.erb`:
195
+
196
+ ``` erb
197
+ <!DOCTYPE html>
198
+ <html>
199
+ <head>
200
+ <meta charset="utf-8">
201
+ <title><%= area :title, "JustinFrench.com" %></title>
202
+ <meta name="description" content="<%= area :description, "This is my website." %>">
203
+ <meta name="keywords" content="<%= area :keywords, "justin, french, ruby, design" %>">
204
+ </head>
205
+ <body>
206
+ <div id="wrapper">
207
+ <div id="content">
208
+ <%= area :content do %>
209
+ <p>Default content goes here.</p>
210
+ <% end %>
211
+ </div>
212
+ <div id="sidebar">
213
+ <%= area :sidebar do %>
214
+ <h2>About Me</h2>
215
+ <p>...</p>
216
+ <% end %>
217
+ </div>
218
+ </div>
219
+ <%= yield %>
220
+ </body>
221
+ </html>
222
+ ```
223
+
224
+ Next, we set-up a `blog` layout that extends `application`, replacing,
225
+ appending & prepending content to the areas we defined earlier.
226
+
227
+ `app/views/layouts/blog.html.erb`:
228
+
229
+ ``` erb
230
+ <%= extends :application do %>
231
+ <% replace :title, "My Blog – " %>
232
+ <% replace :description, "Justin French blogs here on Ruby, Rails, Design, Formtastic, etc" %>
233
+ <% prepend :keywords, "blog, weblog, design links, ruby links, formtastic release notes, " %>
234
+ <%= yield %>
235
+ <% end %>
236
+ ```
237
+
238
+ Now in our blog index view we can use `blog` layout and fill in the areas with
239
+ content specific to the index action.
240
+
241
+
242
+ `app/views/posts/index.html.erb`:
243
+
244
+ ``` erb
245
+ <% replace :content do %>
246
+ <h1>My Blog</h1>
247
+ <%= render @articles %>
248
+ <% end %>
249
+
250
+ <% append :sidebar do %>
251
+ <h2>Blog Roll</h2>
252
+ <%= render @links %>
253
+ <% end %>
254
+ ```
255
+
256
+ We also need to instruct the `PostsController` to use this `blog` layout:
257
+
258
+ `app/controllers/posts_controller.rb`:
259
+
260
+ ``` ruby
261
+ class PostsController < ApplicationController
262
+ layout 'blog'
263
+ end
264
+ ```
265
+
266
+ ---
267
+
268
+ ## Caching
269
+
270
+ nestive-rails works the same way `content_for` does and has the same caching drawbacks. That means that nestive-rails helpers are completely ignored when called from within cached block. You probably don't want to use fragment caching around dynamic nestive-rails areas and have to be extra careful what and how you cache to avoid unpleasant surprises.
271
+
272
+ ---
273
+
274
+ ## Testing
275
+
276
+ 1. Fork this repository
277
+ 2. Clone your forked git locally
278
+ 3. Install dependencies
279
+
280
+ `$ bundle install`
281
+
282
+ 4. Run tests
283
+
284
+ `$ bundle exec rspec`
285
+
286
+ 5. Run RuboCop
287
+
288
+ `$ bundle exec rubocop`
289
+
290
+ ---
291
+
292
+ ## Release
293
+
294
+ 1. Review breaking changes and deprecations in `CHANGELOG.md`
295
+ 2. Change the gem version in `lib/nestive-rails/version.rb`
296
+ 3. Reset `CHANGELOG.md`
297
+ 4. Create a pull request to merge the changes into `master`
298
+ 5. After the pull request was merged, create a new release listing the breaking changes and commits on `master` since the last release.
299
+ 6. The release workflow will publish the gems to RubyGems and the GitHub Package Registry
300
+
301
+ ---
302
+
303
+ ## Contributing
304
+
305
+ We hope that you will consider contributing to nestive-rails. Please read this short overview for some information about how to get started:
306
+
307
+ [Learn more about contributing to this repository](https://github.com/jonhue/nestive-rails/blob/master/CONTRIBUTING.md), [Code of Conduct](https://github.com/jonhue/nestive-rails/blob/master/CODE_OF_CONDUCT.md)
308
+
309
+ ### Semantic Versioning
310
+
311
+ nestive-rails follows Semantic Versioning 2.0 as defined at http://semver.org.