Skip to content

Commit

Permalink
Merge pull request #16 from query-string/master
Browse files Browse the repository at this point in the history
Might be convenient to allow multiple areas purging
  • Loading branch information
rwz committed Oct 5, 2014
2 parents a20f327 + 81b6785 commit 9c699a7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ You can also replace any content provided by parent layouts:

### Removing content with `purge`

You can remove the content of the area:
You can remove the content in the single or in multiple areas

``` erb
<% purge :sidebar %>
<% purge :sidebar, :banner %>
```

... which is equal to:
Expand Down
4 changes: 2 additions & 2 deletions lib/nestive/layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def replace(name, content=nil, &block)
#
# @param [Symbol] name
# A name to identify the area of content you wish to purge
def purge(name)
replace name, nil
def purge(*names)
names.each{|name| replace(name, nil)}
end

private
Expand Down
12 changes: 9 additions & 3 deletions spec/controllers/nestive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,16 @@
end

context '#purge' do
it 'purge area content' do
get :purge
it 'purge single area content' do
get :purge_single
assert_select 'title'
end

it 'purge few areas content' do
get :purge_multiple
assert_select 'title'
assert_select '#some-area'
end
end

context '#extends' do
Expand All @@ -84,4 +90,4 @@
end
end

end
end
3 changes: 0 additions & 3 deletions spec/internal/app/views/nestive/purge.html.erb

This file was deleted.

3 changes: 3 additions & 0 deletions spec/internal/app/views/nestive/purge_multiple.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>multiple purge area</h1>

<% purge :title, :some_area %>
3 changes: 3 additions & 0 deletions spec/internal/app/views/nestive/purge_single.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>single purge area</h1>

<% purge :title %>

0 comments on commit 9c699a7

Please sign in to comment.