Skip to content
Browse files

extend is a ruby keyword, let's go with extends

  • Loading branch information...
1 parent de84db5 commit 181d373a60d7c0cacdf5626c12ce8313a0e97156 @justinfrench committed
Showing with 16 additions and 17 deletions.
  1. +10 −10 README.md
  2. +6 −7 app/helpers/nestive/layout_helper.rb
View
20 README.md
@@ -31,24 +31,24 @@ It's important to note that this isn't *default* content, it *is* the content (u
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`:
- <%= extend :application do %>
+ <%= extends :application do %>
...
<% end %>
You can nest many levels deep:
# app/views/posts/index.html.erb
- <%= extend :blog do %>
+ <%= extends :blog do %>
...
<% end %>
# app/views/layouts/blog.html.erb
- <%= extend :public do %>
+ <%= extends :public do %>
...
<% end %>
# app/views/layouts/public.html.erb
- <%= extend :application do %>
+ <%= extends :application do %>
...
<% end %>
@@ -56,7 +56,7 @@ You can nest many levels deep:
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:
- <%= extend :application do %>
+ <%= extends :application do %>
<%= append :sidebar, "More content." %>
<%= append :sidebar do %>
More content.
@@ -67,7 +67,7 @@ The implementation details are quite different, but the `append` helper works mu
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:
- <%= extend :application do %>
+ <%= extends :application do %>
<%= prepend :sidebar, "Content." %>
<%= prepend :sidebar do %>
Content.
@@ -78,7 +78,7 @@ Exactly what you think it is. The reverse of `append` (duh), adding the new cont
You can also replace any content provided by parent layouts:
- <%= extend :application do %>
+ <%= extends :application do %>
<%= replace :sidebar, "New content." %>
<%= replace :sidebar do %>
New content.
@@ -119,7 +119,7 @@ Set-up a global layout defining some content areas. Note that there is no `<% yi
Next, we set-up a `blog` layout that extends `application`, replacing, appending & prepending content to the areas we defined earlier.
# app/views/layouts/blog.html.erb
- <%= extend :application do %>
+ <%= extends :application do %>
<% replace :title, "My Blog – " %>
<% replace :description, "Justin French blogs here on Ruby, Rails, Design, Formtastic, etc" %>
<% prepend :keywords, "blog, weblog, design links, ruby links, formtastic release notes, " %>
@@ -128,7 +128,7 @@ Next, we set-up a `blog` layout that extends `application`, replacing, appending
Now our blog index view can extend `blog` and fill in the areas with content specific to the index action.
# app/views/posts/index.html.erb
- <%= extend :blog do %>
+ <%= extends :blog do %>
<% replace :content do %>
<h1>My Blog</h1>
<% render @articles %>
@@ -183,4 +183,4 @@ Only testing it with Rails 3.1 (master), but it should work with Rails 2 & 3. We
* reporting issues
* real-world use-cases
* ideas, forks, pull-requests
-* performance testing
+* performance testing
View
13 app/helpers/nestive/layout_helper.rb
@@ -33,7 +33,7 @@ module Nestive
# `content_for` because they're only used modify the content assigned to the area, not retrieve it:
#
# # app/views/layouts/admin.html.erb
- # <%= extend :global do %>
+ # <%= extends :global do %>
# <% prepend :title, "Admin :: " %>
# <% replace :sidebar do %>
# <h2>Quick Links</h2>
@@ -44,7 +44,7 @@ module Nestive
# <% end %>
#
# # app/views/admin/posts/index.html.erb
- # <%= extend :admin do %>
+ # <%= extends :admin do %>
# <% prepend :title, "Posts ::" %>
# <% replace :content do %>
# Normal view stuff goes here.
@@ -60,7 +60,7 @@ module LayoutHelper
# @example Extending the `application` layout to create an `admin` layout
#
# # app/views/layouts/admin.html.erb
- # <%= extend :application do %>
+ # <%= extends :application do %>
# ...
# <% end %>
#
@@ -78,14 +78,13 @@ module LayoutHelper
# end
#
# # app/views/admin/posts/index.html.erb
- # <%= extend :admin do %>
+ # <%= extends :admin do %>
# ...
# <% end %>
- def extend(name, &block)
+ def extends(name, &block)
capture(&block)
render(:file => "layouts/#{name}")
end
- alias_method :extends, :extend
# Defines an area of content in your layout that can be modified or replaced by child layouts
# that extend it. You can optionally add content to an area using either a String, or a block.
@@ -106,7 +105,7 @@ def extend(name, &block)
# <% end %>
#
# @example Define an area in a child layout:
- # <%= extend :global do %>
+ # <%= extends :global do %>
# <%= area :sidebar do %>
# Some content.
# <% end %>

0 comments on commit 181d373

Please sign in to comment.
Something went wrong with that request. Please try again.