Last active
August 29, 2015 14:01
-
-
Save 907th/11bafbcf977f5f76f2dd to your computer and use it in GitHub Desktop.
#content_for with custom parameters
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 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