Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Purge area method

  • Loading branch information...
commit 8517d39896efa960423619f366f014e50c83de8f 1 parent 4f2165d
Alexander Timofeev query-string authored
14 app/helpers/nestive/layout_helper.rb
View
@@ -196,6 +196,18 @@ def replace(name, content=nil, &block)
nil
end
+ # Purge the content of an area previously declared or modified in parent layout(s).
+ #
+ # @example Purge content
+ # <% purge :sidebar %>
+ #
+ # @param [Symbol] name
+ # A name to identify the area of content you wish to purge
+ def purge(name)
+ add_instruction_to_area(name, :replace, [])
+ nil
+ end
+
private
# We record the instructions (declaring, appending, prepending and replacing) for an area of
@@ -235,4 +247,4 @@ def render_area(name)
end
end
-end
+end
9 spec/controllers/nestive_spec.rb
View
@@ -55,7 +55,14 @@
assert_select '#some-area', 'replaced'
end
end
-
+
+ context '#purge' do
+ it 'purge area content' do
+ get :purge
+ assert_select 'title'
+ end
+ end
+
context '#extends' do
it 'extends layouts' do
get :extended_one
3  spec/internal/app/views/nestive/purge.html.erb
View
@@ -0,0 +1,3 @@
+<h1>purge area</h1>
+
+<% purge :title %>
Please sign in to comment.
Something went wrong with that request. Please try again.