Guest User

Untitled

a guest
Jun 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <%
  2. show_empty_sections ||= false
  3. remove_automatic_sections ||= false
  4. hide_sections ||= []
  5.  
  6. sections = [
  7. {:yield => :body_content_title, :fallback => page_title, :id => 'body_content_page_title', :title => true},
  8. {:yield => :body_content_left, :fallback => (@page.present? ? @page[Page.default_parts.first.to_sym] : nil)},
  9. {:yield => :body_content_right, :fallback => (@page.present? ? @page[Page.default_parts.second.to_sym] : nil)}
  10. ].reject {|section| hide_sections.include?(section[:yield]) }
  11.  
  12. css = []
  13. sections.each do |section|
  14. dom_id = (section[:id] ||= section[:yield].to_s)
  15. section[:html] = (yield(section[:yield]))
  16.  
  17. if section[:html].blank? and
  18. !show_empty_sections and
  19. !remove_automatic_sections and
  20. section.keys.include?(:fallback) and
  21. section[:fallback].present?
  22. section[:html] = section[:fallback].to_s.html_safe
  23. end
  24.  
  25. unless section[:html].blank?
  26. unless section[:title]
  27. section[:html] = "<div class='clearfix' id='#{dom_id}'>#{section[:html]}</div>"
  28. else
  29. section[:html] = "<h1 id='#{dom_id}'>#{section[:html]}</h1>"
  30. end
  31. else
  32. css << "no_#{dom_id}"
  33. end
  34. end
  35. -%>
  36. <div id='body_content' class='clearfix<%= " #{css.join(' ')}" if css.any? %>'>
  37. <% sections.each do |s| %>
  38. <%= s[:html].to_s.html_safe %>
  39. <% end %>
  40. </div>
  41. <%= render :partial => '/shared/draft_page_message' unless @page.nil? or @page.live? -%>
Add Comment
Please, Sign In to add comment