Skip to content

Instantly share code, notes, and snippets.

@robhurring
Created September 13, 2010 21:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robhurring/578046 to your computer and use it in GitHub Desktop.
Save robhurring/578046 to your computer and use it in GitHub Desktop.
<div id='sidebar'>
<%= section(:sidebar) || partial(:default_sidebar) %>
</div>
module Sinatra::Helpers
def section(key, *args, &block)
@sections ||= Hash.new{ |k,v| k[v] = [] }
if block_given?
@sections[key] << block
else
@sections[key].inject(''){ |content, block| content << block.call(*args) } if @sections.keys.include?(key)
end
end
end
<% section(:sidebar){ partial :custom_sidebar, :local1 => blah, :local2 => blah } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment