Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.