Skip to content

Instantly share code, notes, and snippets.

@mattly
Created April 6, 2009 23:03
Show Gist options
  • Save mattly/90993 to your computer and use it in GitHub Desktop.
Save mattly/90993 to your computer and use it in GitHub Desktop.
# 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