Permalink
Browse files

added a method for content_for? in sinatra/content_for, and bumped th…

…e version to 1.3.2

Signed-off-by: Ilya Shindyapin <ilya@shindyapin.com>
  • Loading branch information...
1 parent 0fce87a commit 427e167101c074787b22c72fcf1f1dbaffc6acc8 @license2e license2e committed Dec 15, 2011
Showing with 15 additions and 1 deletion.
  1. +14 −0 lib/sinatra/content_for.rb
  2. +1 −1 sinatra-contrib.gemspec
View
@@ -78,6 +78,20 @@ module ContentFor
def content_for(key, &block)
content_blocks[key.to_sym] << capture_later(&block)
end
+
+ # Check if a block of content with the given key was defined. For
+ # example:
+ #
+ # <% content_for :head do %>
+ # <script type="text/javascript" src="/foo.js"></script>
+ # <% end %>
+ #
+ # <% if content_for? :head %>
+ # <span>content "head" was defined.</span>
+ # <% end %>
+ def content_for?(key)
+ content_blocks[key.to_sym].any?
+ end
# Render the captured blocks for a given key. For example:
#
View
@@ -1,7 +1,7 @@
# Run `rake sinatra-contrib.gemspec` to update the gemspec.
Gem::Specification.new do |s|
s.name = "sinatra-contrib"
- s.version = "1.3.1"
+ s.version = "1.3.2"
s.description = "Collection of useful Sinatra extensions"
s.homepage = "http://github.com/sinatra/sinatra-contrib"
s.summary = s.description

0 comments on commit 427e167

Please sign in to comment.