Skip to content

Instantly share code, notes, and snippets.

@parndt
Created June 1, 2010 04:06
Show Gist options
  • Save parndt/420550 to your computer and use it in GitHub Desktop.
Save parndt/420550 to your computer and use it in GitHub Desktop.
<%
show_empty_sections ||= false
remove_automatic_sections ||= false
sections = [
{:yield => :body_content_title, :fallback => page_title, :id => 'body_content_page_title', :title => true},
{:yield => :body_content_left, :fallback => @page[:body]},
{:yield => :body_content_right, :fallback => @page[:side_body]}
]
css = []
sections.each do |section|
dom_id = (section[:id] ||= section[:yield].to_s)
section[:html] = (yield(section[:yield]))
if section[:html].blank? and !show_empty_sections and !remove_automatic_sections
section[:html] = section[:fallback]
end
unless section[:html].blank?
unless section[:title]
section[:html] = "<div class='clearfix' id='#{dom_id}'>#{section[:html]}</div>"
else
section[:html] = "<h1 id='#{dom_id}'>#{section[:html]}</h1>"
end
else
css << "no_#{dom_id}"
end
end
-%>
<div id='body_content' class='clearfix<%= " #{css.join(' ')}" %>'>
<%= sections.collect {|s| s[:html] }.join("\n") %>
</div>
<%= render :partial => '/shared/draft_page_message' unless @page.nil? or @page.live? -%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment