Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

renamed extends() to extend(), aliased for now

  • Loading branch information...
commit e7ca094013fbcbf620e78bb791d1e8a26d0ceb19 1 parent 5134898
@justinfrench authored
Showing with 16 additions and 15 deletions.
  1. +9 −9 README.md
  2. +7 −6 app/helpers/nestive/layout_helper.rb
View
18 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`:
- <%= extends :application do %>
+ <%= extend :application do %>
...
<% end %>
You can nest many levels deep:
# app/views/posts/index.html.erb
- <%= extends :blog do %>
+ <%= extend :blog do %>
...
<% end %>
# app/views/layouts/blog.html.erb
- <%= extends :public do %>
+ <%= extend :public do %>
...
<% end %>
# app/views/layouts/public.html.erb
- <%= extends :application do %>
+ <%= extend :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 an argument or block, adding the new content onto the end of any content previously provided by parent layouts:
- <%= extends :application do %>
+ <%= extend :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:
- <%= extends :application do %>
+ <%= extend :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:
-<%= extends :application do %>
+<%= extend :application do %>
<%= replace :sidebar, "New content." %>
<%= replace :sidebar do %>
New content.
@@ -119,7 +119,7 @@ Set-up a global layout defining some content blocks. Note that there is no `<% y
Next, we set-up a `blog` layout that extends `application`, replacing, appending & prepending content to the blocks we defined earlier.
# app/views/layouts/blog.html.erb
- <%= extends :application do %>
+ <%= extend :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 blocks with content specific to the index action.
# app/views/posts/index.html.erb
- <%= extends :blog do %>
+ <%= extend :blog do %>
<% replace :content do %>
<h1>My Blog</h1>
<% render @articles %>
View
13 app/helpers/nestive/layout_helper.rb
@@ -30,7 +30,7 @@ module Nestive
# either an optional second argument, or with an ERB block):
#
# # app/views/layouts/admin.html.erb
- # <%= extends :global do %>
+ # <%= extend :global do %>
# <% prepend :title, "Admin :: " %>
# <% replace :sidebar do %>
# <h2>Quick Links</h2>
@@ -41,7 +41,7 @@ module Nestive
# <% end %>
#
# # app/views/admin/posts/index.html.erb
- # <%= extends :admin do %>
+ # <%= extend :admin do %>
# <% prepend :title, "Posts ::" %>
# <% replace :content do %>
# Normal view stuff goes here.
@@ -57,7 +57,7 @@ module LayoutHelper
# @example Extending the `application` layout to create an `admin` layout
#
# # app/views/layouts/admin.html.erb
- # <%= extends :application do %>
+ # <%= extend :application do %>
# ...
# <% end %>
#
@@ -75,13 +75,14 @@ module LayoutHelper
# end
#
# # app/views/admin/posts/index.html.erb
- # <%= extends :admin do %>
+ # <%= extend :admin do %>
# ...
# <% end %>
- def extends(name, &block)
+ def extend(name, &block)
capture(&block)
render(:file => "layouts/#{name}")
end
+ alias_method :extends, :extend
# Defines a block of content in your layout that can be modified or replaced by child layouts
# that extend the current layout. You can optionally add content to the block using either a
@@ -103,7 +104,7 @@ def extends(name, &block)
# <% end %>
#
# @example Define a block in a child layout:
- # <%= extends :global do %>
+ # <%= extend :global do %>
# <%= block :sidebar do %>
# Some content.
# <% end %>

0 comments on commit e7ca094

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