Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Purge area method #7

Merged
merged 1 commit into from

2 participants

@query-string

Clean area method with non generic name

@rwz
Owner

Could you please rebase against current master?

@rwz rwz merged commit c759999 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 14, 2013
  1. @query-string

    Purge area method

    query-string authored
This page is out of date. Refresh to see the latest.
View
14 app/helpers/nestive/layout_helper.rb
@@ -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
View
9 spec/controllers/nestive_spec.rb
@@ -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
View
3  spec/internal/app/views/nestive/purge.html.erb
@@ -0,0 +1,3 @@
+<h1>purge area</h1>
+
+<% purge :title %>
Something went wrong with that request. Please try again.