nestive 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +45 -46
- data/README.md +139 -107
- data/lib/nestive/version.rb +1 -1
- data/nestive.gemspec +3 -3
- metadata +28 -27
data/Gemfile.lock
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nestive (0.
|
5
|
-
rails (
|
4
|
+
nestive (0.2.0)
|
5
|
+
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (3.2.
|
11
|
-
actionpack (= 3.2.
|
10
|
+
actionmailer (3.2.11)
|
11
|
+
actionpack (= 3.2.11)
|
12
12
|
mail (~> 2.4.4)
|
13
|
-
actionpack (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
actionpack (3.2.11)
|
14
|
+
activemodel (= 3.2.11)
|
15
|
+
activesupport (= 3.2.11)
|
16
16
|
builder (~> 3.0.0)
|
17
17
|
erubis (~> 2.7.0)
|
18
18
|
journey (~> 1.0.4)
|
19
19
|
rack (~> 1.4.0)
|
20
20
|
rack-cache (~> 1.2)
|
21
21
|
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.1
|
23
|
-
activemodel (3.2.
|
24
|
-
activesupport (= 3.2.
|
22
|
+
sprockets (~> 2.2.1)
|
23
|
+
activemodel (3.2.11)
|
24
|
+
activesupport (= 3.2.11)
|
25
25
|
builder (~> 3.0.0)
|
26
|
-
activerecord (3.2.
|
27
|
-
activemodel (= 3.2.
|
28
|
-
activesupport (= 3.2.
|
26
|
+
activerecord (3.2.11)
|
27
|
+
activemodel (= 3.2.11)
|
28
|
+
activesupport (= 3.2.11)
|
29
29
|
arel (~> 3.0.2)
|
30
30
|
tzinfo (~> 0.3.29)
|
31
|
-
activeresource (3.2.
|
32
|
-
activemodel (= 3.2.
|
33
|
-
activesupport (= 3.2.
|
34
|
-
activesupport (3.2.
|
31
|
+
activeresource (3.2.11)
|
32
|
+
activemodel (= 3.2.11)
|
33
|
+
activesupport (= 3.2.11)
|
34
|
+
activesupport (3.2.11)
|
35
35
|
i18n (~> 0.6)
|
36
36
|
multi_json (~> 1.0)
|
37
37
|
arel (3.0.2)
|
38
38
|
builder (3.0.4)
|
39
|
-
combustion (0.3.
|
39
|
+
combustion (0.3.3)
|
40
40
|
rails (>= 3.0.0)
|
41
41
|
thor (>= 0.14.6)
|
42
42
|
diff-lcs (1.1.3)
|
@@ -44,57 +44,56 @@ GEM
|
|
44
44
|
hike (1.2.1)
|
45
45
|
i18n (0.6.1)
|
46
46
|
journey (1.0.4)
|
47
|
-
json (1.7.
|
47
|
+
json (1.7.6)
|
48
48
|
mail (2.4.4)
|
49
49
|
i18n (>= 0.4.0)
|
50
50
|
mime-types (~> 1.16)
|
51
51
|
treetop (~> 1.4.8)
|
52
52
|
mime-types (1.19)
|
53
|
-
multi_json (1.
|
53
|
+
multi_json (1.5.0)
|
54
54
|
polyglot (0.3.3)
|
55
|
-
rack (1.4.
|
55
|
+
rack (1.4.4)
|
56
56
|
rack-cache (1.2)
|
57
57
|
rack (>= 0.4)
|
58
|
-
rack-ssl (1.3.
|
58
|
+
rack-ssl (1.3.3)
|
59
59
|
rack
|
60
60
|
rack-test (0.6.2)
|
61
61
|
rack (>= 1.0)
|
62
|
-
rails (3.2.
|
63
|
-
actionmailer (= 3.2.
|
64
|
-
actionpack (= 3.2.
|
65
|
-
activerecord (= 3.2.
|
66
|
-
activeresource (= 3.2.
|
67
|
-
activesupport (= 3.2.
|
62
|
+
rails (3.2.11)
|
63
|
+
actionmailer (= 3.2.11)
|
64
|
+
actionpack (= 3.2.11)
|
65
|
+
activerecord (= 3.2.11)
|
66
|
+
activeresource (= 3.2.11)
|
67
|
+
activesupport (= 3.2.11)
|
68
68
|
bundler (~> 1.0)
|
69
|
-
railties (= 3.2.
|
70
|
-
railties (3.2.
|
71
|
-
actionpack (= 3.2.
|
72
|
-
activesupport (= 3.2.
|
69
|
+
railties (= 3.2.11)
|
70
|
+
railties (3.2.11)
|
71
|
+
actionpack (= 3.2.11)
|
72
|
+
activesupport (= 3.2.11)
|
73
73
|
rack-ssl (~> 1.3.2)
|
74
74
|
rake (>= 0.8.7)
|
75
75
|
rdoc (~> 3.4)
|
76
76
|
thor (>= 0.14.6, < 2.0)
|
77
|
-
rake (0.
|
77
|
+
rake (10.0.3)
|
78
78
|
rdoc (3.12)
|
79
79
|
json (~> 1.4)
|
80
|
-
rspec (2.
|
81
|
-
|
82
|
-
rspec-expectations (~> 2.11.0)
|
83
|
-
rspec-mocks (~> 2.11.0)
|
84
|
-
rspec-core (2.11.1)
|
85
|
-
rspec-expectations (2.11.3)
|
80
|
+
rspec-core (2.12.2)
|
81
|
+
rspec-expectations (2.12.1)
|
86
82
|
diff-lcs (~> 1.1.3)
|
87
|
-
rspec-mocks (2.
|
88
|
-
rspec-rails (2.
|
83
|
+
rspec-mocks (2.12.2)
|
84
|
+
rspec-rails (2.12.2)
|
89
85
|
actionpack (>= 3.0)
|
90
86
|
activesupport (>= 3.0)
|
91
87
|
railties (>= 3.0)
|
92
|
-
rspec (~> 2.
|
93
|
-
|
88
|
+
rspec-core (~> 2.12.0)
|
89
|
+
rspec-expectations (~> 2.12.0)
|
90
|
+
rspec-mocks (~> 2.12.0)
|
91
|
+
sprockets (2.2.2)
|
94
92
|
hike (~> 1.2)
|
93
|
+
multi_json (~> 1.0)
|
95
94
|
rack (~> 1.0)
|
96
95
|
tilt (~> 1.1, != 1.3.0)
|
97
|
-
thor (0.
|
96
|
+
thor (0.17.0)
|
98
97
|
tilt (1.3.3)
|
99
98
|
treetop (1.4.12)
|
100
99
|
polyglot
|
@@ -105,6 +104,6 @@ PLATFORMS
|
|
105
104
|
ruby
|
106
105
|
|
107
106
|
DEPENDENCIES
|
108
|
-
combustion (~> 0.3.
|
107
|
+
combustion (~> 0.3.3)
|
109
108
|
nestive!
|
110
|
-
rspec-rails (~> 2.
|
109
|
+
rspec-rails (~> 2.12)
|
data/README.md
CHANGED
@@ -16,15 +16,19 @@ Nestive is *better* because it addresses these problems.
|
|
16
16
|
|
17
17
|
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:
|
18
18
|
|
19
|
-
|
19
|
+
``` erb
|
20
|
+
<%= area :sidebar %>
|
21
|
+
```
|
20
22
|
|
21
23
|
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:
|
22
24
|
|
23
|
-
|
25
|
+
``` erb
|
26
|
+
<%= area :sidebar, "Some Content Here" %>
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
<%= area :sidebar do %>
|
29
|
+
Some Content Here
|
30
|
+
<% end %>
|
31
|
+
```
|
28
32
|
|
29
33
|
It's important to note that this isn't *default* content, it *is* the content (unless a child changes it).
|
30
34
|
|
@@ -32,147 +36,175 @@ It's important to note that this isn't *default* content, it *is* the content (u
|
|
32
36
|
|
33
37
|
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:
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
``` erb
|
40
|
+
<%= extends :application do %>
|
41
|
+
<% append :sidebar, "More content." %>
|
42
|
+
<% append :sidebar do %>
|
43
|
+
More content.
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
```
|
41
47
|
|
42
48
|
### Prepending content to an area:
|
43
49
|
|
44
50
|
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:
|
45
51
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
``` erb
|
53
|
+
<%= extends :application do %>
|
54
|
+
<%= prepend :sidebar, "Content." %>
|
55
|
+
<%= prepend :sidebar do %>
|
56
|
+
Content.
|
57
|
+
<% end %>
|
58
|
+
<% end %>
|
59
|
+
```
|
52
60
|
|
53
61
|
### Replacing content
|
54
62
|
|
55
63
|
You can also replace any content provided by parent layouts:
|
56
64
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
65
|
+
``` erb
|
66
|
+
<%= extends :application do %>
|
67
|
+
<%= replace :sidebar, "New content." %>
|
68
|
+
<%= replace :sidebar do %>
|
69
|
+
New content.
|
70
|
+
<% end %>
|
71
|
+
<% end %>
|
72
|
+
```
|
63
73
|
|
64
74
|
### Extending a layout in a child layout (or view):
|
65
75
|
|
66
76
|
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`:
|
67
77
|
|
68
|
-
|
69
|
-
|
70
|
-
|
78
|
+
``` erb
|
79
|
+
<%= extends :application do %>
|
80
|
+
...
|
81
|
+
<% end %>
|
82
|
+
```
|
71
83
|
|
72
84
|
You can nest many levels deep:
|
73
85
|
|
74
|
-
|
75
|
-
<!DOCTYPE html>
|
76
|
-
<html>
|
77
|
-
<head>
|
78
|
-
<%= area :head do %>
|
79
|
-
<title><%= area :title, 'Nestive' %></title>
|
80
|
-
<% end %>
|
81
|
-
</head>
|
82
|
-
<body>
|
83
|
-
<%= yield %>
|
84
|
-
</body>
|
85
|
-
</html>
|
86
|
-
|
87
|
-
# app/views/layouts/with_sidebar.html.erb
|
88
|
-
<%= extends :application do %>
|
89
|
-
<div class="sidebar"><%= area(:sidebar) do %>
|
90
|
-
here goes sidebar
|
91
|
-
<% end %></div>
|
92
|
-
<%= yield -%>
|
93
|
-
<% end %>
|
94
|
-
|
95
|
-
# app/views/layouts/blog_posts.html.erb
|
96
|
-
<%= extends :with_sidebar do %>
|
97
|
-
<% append :sidebar do %>
|
98
|
-
Blog archive:
|
99
|
-
<%= render_blog_archive %>
|
100
|
-
<% end %>
|
86
|
+
`app/views/layouts/application.html.erb`:
|
101
87
|
|
102
|
-
|
103
|
-
|
88
|
+
``` erb
|
89
|
+
<!DOCTYPE html>
|
90
|
+
<html>
|
91
|
+
<head>
|
92
|
+
<%= area :head do %>
|
93
|
+
<title><%= area :title, 'Nestive' %></title>
|
104
94
|
<% end %>
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
95
|
+
</head>
|
96
|
+
<body>
|
97
|
+
<%= yield %>
|
98
|
+
</body>
|
99
|
+
</html>
|
100
|
+
```
|
101
|
+
|
102
|
+
`app/views/layouts/with_sidebar.html.erb`:
|
103
|
+
|
104
|
+
``` erb
|
105
|
+
<%= extends :application do %>
|
106
|
+
<div class="sidebar"><%= area(:sidebar) do %>
|
107
|
+
here goes sidebar
|
108
|
+
<% end %></div>
|
109
|
+
<%= yield -%>
|
110
|
+
<% end %>
|
111
|
+
```
|
112
|
+
|
113
|
+
`app/views/layouts/blog_posts.html.erb`:
|
114
|
+
|
115
|
+
``` erb
|
116
|
+
<%= extends :with_sidebar do %>
|
117
|
+
<% append :sidebar do %>
|
118
|
+
Blog archive:
|
119
|
+
<%= render_blog_archive %>
|
120
|
+
<% end %>
|
121
|
+
|
122
|
+
<% append :head do %>
|
123
|
+
<%= javascript_include_tag 'fancy_blog_archive_tag_cloud' %>
|
124
|
+
<% end %>
|
125
|
+
|
126
|
+
<%= yield %>
|
127
|
+
<% end %>
|
128
|
+
```
|
110
129
|
|
111
130
|
## The token blog example
|
112
131
|
|
113
132
|
Set-up a global layout defining some content areas.
|
114
133
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
`app/views/layouts/application.html.erb`:
|
135
|
+
|
136
|
+
``` erb
|
137
|
+
<!DOCTYPE html>
|
138
|
+
<html>
|
139
|
+
<head>
|
140
|
+
<meta charset="utf-8">
|
141
|
+
<title><%= area :title, "JustinFrench.com" %></title>
|
142
|
+
<meta name="description" content="<%= area :description, "This is my website." %>">
|
143
|
+
<meta name="keywords" content="<%= area :keywords, "justin, french, ruby, design" %>">
|
144
|
+
</head>
|
145
|
+
<body>
|
146
|
+
<div id="wrapper">
|
147
|
+
<div id="content">
|
148
|
+
<%= area :content do %>
|
149
|
+
<p>Default content goes here.</p>
|
150
|
+
<% end %>
|
151
|
+
</div>
|
152
|
+
<div id="sidebar">
|
153
|
+
<%= area :sidebar do %>
|
154
|
+
<h2>About Me</h2>
|
155
|
+
<p>...</p>
|
156
|
+
<% end %>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
<%= yield %>
|
160
|
+
</body>
|
161
|
+
</html>
|
162
|
+
```
|
141
163
|
|
142
164
|
Next, we set-up a `blog` layout that extends `application`, replacing, appending & prepending content to the areas we defined earlier.
|
143
165
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
166
|
+
`app/views/layouts/blog.html.erb`:
|
167
|
+
|
168
|
+
``` erb
|
169
|
+
<%= extends :application do %>
|
170
|
+
<% replace :title, "My Blog – " %>
|
171
|
+
<% replace :description, "Justin French blogs here on Ruby, Rails, Design, Formtastic, etc" %>
|
172
|
+
<% prepend :keywords, "blog, weblog, design links, ruby links, formtastic release notes, " %>
|
173
|
+
<%= yield %>
|
174
|
+
<% end %>
|
175
|
+
```
|
151
176
|
|
152
177
|
Now in our blog index view we can use `blog` layout and fill in the areas with content specific to the index action.
|
153
178
|
|
154
|
-
# app/views/posts/index.html.erb
|
155
|
-
<% replace :content do %>
|
156
|
-
<h1>My Blog</h1>
|
157
|
-
<%= render @articles %>
|
158
|
-
<% end %>
|
159
179
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
180
|
+
`app/views/posts/index.html.erb`:
|
181
|
+
|
182
|
+
``` erb
|
183
|
+
<% replace :content do %>
|
184
|
+
<h1>My Blog</h1>
|
185
|
+
<%= render @articles %>
|
186
|
+
<% end %>
|
187
|
+
|
188
|
+
<% append :sidebar do %>
|
189
|
+
<h2>Blog Roll</h2>
|
190
|
+
<%= render @links %>
|
191
|
+
<% end %>
|
192
|
+
```
|
164
193
|
|
165
194
|
We also need to instruct the `PostsController` to use this `blog` layout:
|
166
195
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
196
|
+
`app/controllers/posts_controller.rb`:
|
197
|
+
|
198
|
+
``` ruby
|
199
|
+
class PostsController < ApplicationController
|
200
|
+
layout 'blog'
|
201
|
+
end
|
202
|
+
```
|
171
203
|
|
172
204
|
|
173
205
|
## Installation
|
174
206
|
|
175
|
-
* add `gem 'nestive', '~> 0.2'` to your
|
207
|
+
* add `gem 'nestive', '~> 0.2'` to your Gemfile
|
176
208
|
* run `bundle`
|
177
209
|
|
178
210
|
## Compatibility
|
data/lib/nestive/version.rb
CHANGED
data/nestive.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
|
22
|
-
s.add_dependency 'rails', '
|
23
|
-
s.add_development_dependency 'combustion', '~> 0.3.
|
24
|
-
s.add_development_dependency 'rspec-rails', '~> 2.
|
22
|
+
s.add_dependency 'rails', '>= 3.0.0'
|
23
|
+
s.add_development_dependency 'combustion', '~> 0.3.3'
|
24
|
+
s.add_development_dependency 'rspec-rails', '~> 2.12'
|
25
25
|
|
26
26
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nestive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Justin French
|
@@ -10,56 +10,56 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
+
prerelease: false
|
17
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
none: false
|
23
|
+
type: :runtime
|
16
24
|
name: rails
|
17
25
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
26
|
requirements:
|
20
|
-
- -
|
27
|
+
- - ! '>='
|
21
28
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
|
29
|
+
version: 3.0.0
|
30
|
+
none: false
|
31
|
+
- !ruby/object:Gem::Dependency
|
24
32
|
prerelease: false
|
25
33
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
34
|
requirements:
|
28
35
|
- - ~>
|
29
36
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
31
|
-
|
37
|
+
version: 0.3.3
|
38
|
+
none: false
|
39
|
+
type: :development
|
32
40
|
name: combustion
|
33
41
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
42
|
requirements:
|
36
43
|
- - ~>
|
37
44
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.3.
|
39
|
-
|
45
|
+
version: 0.3.3
|
46
|
+
none: false
|
47
|
+
- !ruby/object:Gem::Dependency
|
40
48
|
prerelease: false
|
41
49
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
50
|
requirements:
|
44
51
|
- - ~>
|
45
52
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
|
53
|
+
version: '2.12'
|
54
|
+
none: false
|
55
|
+
type: :development
|
48
56
|
name: rspec-rails
|
49
57
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version: '2.
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
version: '2.12'
|
58
62
|
none: false
|
59
|
-
requirements:
|
60
|
-
- - ~>
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '2.11'
|
63
63
|
description: A Rails plugin/gem for awesome nested templates and layouts
|
64
64
|
email:
|
65
65
|
- justin@indent.com.au
|
@@ -110,20 +110,20 @@ rdoc_options: []
|
|
110
110
|
require_paths:
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
113
|
requirements:
|
115
114
|
- - ! '>='
|
116
115
|
- !ruby/object:Gem::Version
|
117
116
|
version: '0'
|
118
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
117
|
none: false
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
119
|
requirements:
|
121
120
|
- - ! '>='
|
122
121
|
- !ruby/object:Gem::Version
|
123
122
|
version: '0'
|
123
|
+
none: false
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project: nestive
|
126
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.25
|
127
127
|
signing_key:
|
128
128
|
specification_version: 3
|
129
129
|
summary: A Rails plugin/gem for awesome nested templates and layouts
|
@@ -145,3 +145,4 @@ test_files:
|
|
145
145
|
- spec/internal/log/.gitignore
|
146
146
|
- spec/internal/public/favicon.ico
|
147
147
|
- spec/spec_helper.rb
|
148
|
+
has_rdoc:
|