".
html_safe +
builder.render :my_block
output
```
> The above code will output the following:
```
Render Before Skip:
"before_all" Hook
"around_all" Hook Before
wrap_all Wrapper Before
wrap_each Wrapper Before
"around" Hook Before
"before" Hook
wrap_with Wrapper Before
"surround" Hook Before
"prepend" Hook
My Block
"append" Hook
"surround" Hook After
wrap_with Wrapper After
"after" Hook
"around" Hook After
wrap_each Wrapper After
wrap_all Wrapper After
"around_all" Hook After
"after_all" Hook
Render After Skip:
"before_all" Hook
"around_all" Hook Before
wrap_all Wrapper Before
wrap_each Wrapper Before
"around" Hook Before
"before" Hook
"after" Hook
"around" Hook After
wrap_each Wrapper After
wrap_all Wrapper After
"around_all" Hook After
"after_all" Hook
```
A block may be skipped using the #skip method.
Calling #skip has the effect of skipping rendering of the block itself, and any "prepend" hooks, "append" hooks, "surround" hooks, and the "wrap_with" wrapper that might have been associated with the block being skipped.
Any "before" hooks, "before_all" hooks, "after" hooks, "after_all" hooks, "around" hooks, "around_all" hooks, the "wrap_all" wrapper, and the "wrap_each" wrapper will continue to be rendered when the block is skipped. See [Skipping the Block and its Hooks](#Skipping the Block and its Hooks) for skipping everything.
### With a Collection
```erb
<% blocks.define :my_block,
collection: ["a", "b"] %>
".
html_safe +
builder.render :my_block
output
```
> The above code will output the following:
```
Render Before Skip:
"before_all" Hook
"around_all" Hook Before
wrap_all Wrapper Before
wrap_each Wrapper Before for item "a"
"around" Hook Before for item "a"
"before" Hook for item "a"
wrap_with Wrapper Before for item "a"
"surround" Hook Before for item "a"
"prepend" Hook for item "a"
My Block
"append" Hook for item "a"
"surround" Hook After for item "a"
wrap_with Wrapper After for item "a"
"after" Hook for item "a"
"around" Hook After for item "a"
wrap_each Wrapper After for item "a"
wrap_each Wrapper Before for item "b"
"around" Hook Before for item "b"
"before" Hook for item "b"
wrap_with Wrapper Before for item "b"
"surround" Hook Before for item "b"
"prepend" Hook for item "b"
My Block
"append" Hook for item "b"
"surround" Hook After for item "b"
wrap_with Wrapper After for item "b"
"after" Hook for item "b"
"around" Hook After for item "b"
wrap_each Wrapper After for item "b"
wrap_all Wrapper After
"around_all" Hook After
"after_all" Hook
Render After Skip:
"before_all" Hook
"around_all" Hook Before
wrap_all Wrapper Before
wrap_each Wrapper Before for item "a"
"around" Hook Before for item "a"
"before" Hook for item "a"
"after" Hook for item "a"
"around" Hook After for item "a"
wrap_each Wrapper After for item "a"
wrap_each Wrapper Before for item "b"
"around" Hook Before for item "b"
"before" Hook for item "b"
"after" Hook for item "b"
"around" Hook After for item "b"
wrap_each Wrapper After for item "b"
wrap_all Wrapper After
"around_all" Hook After
"after_all" Hook
```
A block with a collection can also be skipped, though the resulting output may not be desired.
Calling #skip on a block with a collection has the effect of skipping rendering of the block itself, and any "prepend" hooks, "append" hooks, "surround" hooks, and the "wrap_with" wrapper that might have been associated with the block being skipped.
Any "before" hooks, "before_all" hooks, "after" hooks, "after_all" hooks, "around" hooks, "around_all" hooks, the "wrap_all" wrapper, and the "wrap_each" wrapper will continue to be rendered when the block is skipped. All the hooks and wrappers, with the exception of the "around_all", "wrap_all", "before_all", and "after_all" ones, will be rendered for each item in the collection (this behavior will likely change in a future release of Blocks).
See [Skipping the Block and its Hooks](#Skipping the Block and its Hooks) for skipping everything.
## Skipping the Block and its Hooks
```erb
<% blocks.skip_completely :my_block %>
<%= blocks.render :my_block do %>
Hello
<% end %>
```
```haml
- blocks.skip_completely :my_block
= blocks.render :my_block do
Hello
```
```ruby
# where builder is an instance
# of Blocks::Builder
builder.skip_completely :my_block
builder.render :my_block do
"Hello"
end
```
> There will be no output from the above command
Because calling #skip can still have the effect of rendering some of the hooks and wrappers for a particular block (before, after, around, before_all, after_all, wrap_all, wrap_each will still be rendered), there is the need for a second type of skip, called #skip_completely, which will skip the block and all associated hooks and wrappers.