Class: Refinery::Pages::SectionPresenter
- Inherits:
-
Object
- Object
- Refinery::Pages::SectionPresenter
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/presenters/refinery/pages/section_presenter.rb
Overview
Knows how to build the html for a section. A section is part of the visible html, that has content wrapped in some particular markup. Construct with the relevant options, and then call wrapped_html to get the resultant html.
The content rendered will usually be the value of fallback_html, unless an override_html is specified. However, on rendering, you can elect not display sections that have no override_html by passing in false for can_use_fallback.
Sections may be hidden, in which case they wont display at all.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fallback_html ⇒ Object
readonly
Returns the value of attribute fallback_html.
-
#hidden ⇒ Object
(also: #hidden?)
readonly
Returns the value of attribute hidden.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#override_html ⇒ Object
Returns the value of attribute override_html.
Instance Method Summary collapse
- #has_content?(can_use_fallback = true) ⇒ Boolean
- #hide ⇒ Object
-
#initialize(initial_hash = {}) ⇒ SectionPresenter
constructor
A new instance of SectionPresenter.
- #not_present_css_class ⇒ Object
- #visible? ⇒ Boolean
- #wrapped_html(can_use_fallback = true) ⇒ Object
Constructor Details
#initialize(initial_hash = {}) ⇒ SectionPresenter
Returns a new instance of SectionPresenter.
15 16 17 18 19 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 15 def initialize(initial_hash = {}) initial_hash.map do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#fallback_html ⇒ Object
Returns the value of attribute fallback_html.
21 22 23 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 21 def fallback_html @fallback_html end |
#hidden ⇒ Object Also known as:
Returns the value of attribute hidden.
21 22 23 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 21 def hidden @hidden end |
#id ⇒ Object
Returns the value of attribute id.
21 22 23 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 21 def id @id end |
#override_html ⇒ Object
Returns the value of attribute override_html.
23 24 25 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 23 def override_html @override_html end |
Instance Method Details
#has_content?(can_use_fallback = true) ⇒ Boolean
29 30 31 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 29 def has_content?(can_use_fallback = true) visible? && content_html(can_use_fallback).present? end |
#hide ⇒ Object
42 43 44 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 42 def hide self.hidden = true end |
#not_present_css_class ⇒ Object
46 47 48 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 46 def not_present_css_class "no_#{id}" end |
#visible? ⇒ Boolean
25 26 27 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 25 def visible? !hidden? end |
#wrapped_html(can_use_fallback = true) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/presenters/refinery/pages/section_presenter.rb', line 33 def wrapped_html(can_use_fallback = true) return if hidden? content = content_html(can_use_fallback) if content.present? wrap_content_in_tag(content) end end |