Skip to content

Instantly share code, notes, and snippets.

@907th
Last active August 29, 2015 14:01
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 907th/11bafbcf977f5f76f2dd to your computer and use it in GitHub Desktop.
Save 907th/11bafbcf977f5f76f2dd to your computer and use it in GitHub Desktop.
#content_for with custom parameters
module ParameterizedContentForHelper
# Warning! Content is being rewritten on each next call!
def parameterized_content_for(name, *params, &block)
@parameterized_content_for ||= {}
if block_given?
@parameterized_content_for[name] = block
else
block = @parameterized_content_for[name]
capture *params, &block if block
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment