Guest User

Untitled

a guest
Feb 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. module ContentForHelpers
  2. def content_for?(name, options = {}, &block)
  3. has_content = (!instance_variable_get("@content_for_#{name}").strip.blank? rescue nil)
  4. should_process = options[:negate] ? !has_content : has_content
  5. if should_process && block_given?
  6. concat(capture(&block), block.binding)
  7. end
  8. return should_process
  9. end
  10.  
  11. def no_content_for?(name,&block)
  12. content_for?(name, :negate => true, &block)
  13. end
  14.  
  15. def get_content_for(name)
  16. instance_variable_get("@content_for_#{name}")
  17. end
  18. end
Add Comment
Please, Sign In to add comment