Skip to content

Commit

Permalink
follow up #1225
Browse files Browse the repository at this point in the history
  • Loading branch information
namusyaka committed Dec 21, 2018
1 parent 84b290a commit 69956da
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions sinatra-contrib/lib/sinatra/content_for.rb
Expand Up @@ -129,11 +129,9 @@ module ContentFor
# Your blocks can also receive values, which are passed to them
# by <tt>yield_content</tt>
def content_for(key, value = nil, options = {}, &block)
key = key.to_sym

block ||= proc { |*| value }
clear_content_for(key) if options[:flush]
content_blocks[key] << capture_later(&block)
content_blocks[key.to_sym] << capture_later(&block)
end

# Check if a block of content with the given key was defined. For
Expand Down Expand Up @@ -175,11 +173,10 @@ def clear_content_for(key)
# Would pass <tt>1</tt> and <tt>2</tt> to all the blocks registered
# for <tt>:head</tt>.
def yield_content(key, *args, &block)
key = key.to_sym
if block_given? && !content_for?(key)
haml? ? capture_haml(*args, &block) : yield(*args)
else
content = content_blocks[key].map { |b| capture(*args, &b) }
content = content_blocks[key.to_sym].map { |b| capture(*args, &b) }
content.join.tap do |c|
if block_given? && (erb? || erubi? || erubis?)
@_out_buf << c
Expand Down

0 comments on commit 69956da

Please sign in to comment.