Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created September 10, 2008 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseppstein/9824 to your computer and use it in GitHub Desktop.
Save chriseppstein/9824 to your computer and use it in GitHub Desktop.
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