Class: Refinery::Pages::SectionPresenter
- Inherits:
-
Object
- Object
- Refinery::Pages::SectionPresenter
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- pages/lib/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)
-
- (Object) fallback_html
readonly
Returns the value of attribute fallback_html.
-
- (Object) hidden
(also: #hidden?)
readonly
Returns the value of attribute hidden.
-
- (Object) id
readonly
Returns the value of attribute id.
-
- (Object) override_html
Returns the value of attribute override_html.
Instance Method Summary (collapse)
- - (Boolean) has_content?(can_use_fallback = true)
- - (Object) hide
-
- (SectionPresenter) initialize(initial_hash = {})
constructor
A new instance of SectionPresenter.
- - (Object) not_present_css_class
- - (Boolean) visible?
- - (Object) wrapped_html(can_use_fallback = true)
Constructor Details
- (SectionPresenter) initialize(initial_hash = {})
A new instance of SectionPresenter
15 16 17 18 19 |
# File 'pages/lib/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
- (Object) fallback_html
Returns the value of attribute fallback_html
21 22 23 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 21 def fallback_html @fallback_html end |
- (Object) hidden Also known as:
Returns the value of attribute hidden
21 22 23 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 21 def hidden @hidden end |
- (Object) id
Returns the value of attribute id
21 22 23 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 21 def id @id end |
- (Object) override_html
Returns the value of attribute override_html
23 24 25 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 23 def override_html @override_html end |
Instance Method Details
- (Boolean) has_content?(can_use_fallback = true)
29 30 31 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 29 def has_content?(can_use_fallback = true) visible? && content_html(can_use_fallback).present? end |
- (Object) hide
42 43 44 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 42 def hide self.hidden = true end |
- (Object) not_present_css_class
46 47 48 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 46 def not_present_css_class "no_#{id}" end |
- (Boolean) visible?
25 26 27 |
# File 'pages/lib/refinery/pages/section_presenter.rb', line 25 def visible? !hidden? end |
- (Object) wrapped_html(can_use_fallback = true)
33 34 35 36 37 38 39 40 |
# File 'pages/lib/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 |