Created
September 10, 2008 04:43
-
-
Save chriseppstein/9824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ContentForHelpers | |
def content_for?(name, options = {}, &block) | |
has_content = (!instance_variable_get("@content_for_#{name}").strip.blank? rescue nil) | |
should_process = options[:negate] ? !has_content : has_content | |
if should_process && block_given? | |
concat(capture(&block), block.binding) | |
end | |
return should_process | |
end | |
def no_content_for?(name,&block) | |
content_for?(name, :negate => true, &block) | |
end | |
def get_content_for(name) | |
instance_variable_get("@content_for_#{name}") | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment