Skip to content

Instantly share code, notes, and snippets.

@sdhull
Created November 8, 2010 23:23
Show Gist options
  • Save sdhull/668461 to your computer and use it in GitHub Desktop.
Save sdhull/668461 to your computer and use it in GitHub Desktop.
the problem
class ViewContext
def initialize(*args)
@_content_for = Hash.new
end
def content_for(name, content, &block)
content = capture(&block) if block_given?
@_content_for[name] = content
end
end
class ActionController::Base
def view_context
ViewContext.new
end
end
#####
@controller = ActionController::Base.new
@controller.view_context.content_for :foo, :bar
@controller.view_context.instance_variable_get "@_content_for" # => {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment