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 +4 -4
- data/CHANGELOG.md +13 -14
- data/LICENSE +42 -21
- data/README.md +311 -317
- data/lib/nestive-rails.rb +9 -9
- data/lib/nestive-rails/layout_helper.rb +260 -245
- data/lib/nestive-rails/railtie.rb +13 -13
- data/lib/nestive-rails/version.rb +5 -5
- metadata +19 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb88c789b7e51155d7160366f7f589eac5fa473a4a7b42be7293af40f75f2c13
|
4
|
+
data.tar.gz: 33b41325df206030f5167b30efe18eff98c767b0a64ecb98dc8c61b419851356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8e267cc820094dd88b7b1c6a828e441aae4772b6cf3fa95e734196d9c04ae9d4183e0c6339fddd5286d5ede26d3f460eb7d0f0cbc98b2b4d0dfbfc76c44252
|
7
|
+
data.tar.gz: dcfac54b385a4f76d763d74b7e0198248abb79fa11f1f55a5f75a0b5628f2dc93968e09d918ae82e2a23f1dd707775eb0f2b5db1005888d0e1b71f06fb48a815
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,13 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
###
|
8
|
-
|
9
|
-
*
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
[
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
* [
|
19
|
-
* [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
* [
|
27
|
-
* [
|
28
|
-
* [To Do](#to-do)
|
29
|
-
* [Contributing](#contributing)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
<%=
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<%=
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<% purge :sidebar %>
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
<
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
<
|
200
|
-
<
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
<
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
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.
|