Created
April 6, 2009 23:03
-
-
Save mattly/90993 to your computer and use it in GitHub Desktop.
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
# todo: add handlers for erb blocks | |
# example: | |
# - content_for :head do | |
# :javascript | |
# var foo = "foobar" | |
# and then in where you want that: | |
# = content_for :head | |
def content_for bin, content=nil, &block | |
@content_for ||= Hash.new {|h,k| h[k] = []} | |
if content || block_given? | |
content ||= [content] | |
content << capture_haml(&block) if block_given? and block_is_haml? block | |
@content_for[bin.to_s] += [content].flatten.compact | |
else | |
@content_for[bin.to_s].join("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment