Class: SimpleNavigation::Renderer::Base
- Inherits:
-
Object
- Object
- SimpleNavigation::Renderer::Base
- Extended by:
- Forwardable
- Defined in:
- lib/simple_navigation/renderer/base.rb
Overview
This is the base class for all renderers.
A renderer is responsible for rendering an ItemContainer and its containing items to HTML.
Direct Known Subclasses
Breadcrumbs, Json, Links, List, Text
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #expand_all? ⇒ Boolean
- #include_sub_navigation?(item) ⇒ Boolean
-
#initialize(options) ⇒ Base
constructor
:nodoc:.
- #level ⇒ Object
-
#render(item_container) ⇒ Object
Renders the specified ItemContainer to HTML.
- #render_sub_navigation_for(item) ⇒ Object
- #skip_if_empty? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Base
:nodoc:
16 17 18 19 |
# File 'lib/simple_navigation/renderer/base.rb', line 16 def initialize() #:nodoc: @options = @adapter = SimpleNavigation.adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
12 13 14 |
# File 'lib/simple_navigation/renderer/base.rb', line 12 def adapter @adapter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/simple_navigation/renderer/base.rb', line 12 def @options end |
Instance Method Details
#expand_all? ⇒ Boolean
21 22 23 |
# File 'lib/simple_navigation/renderer/base.rb', line 21 def !![:expand_all] end |
#include_sub_navigation?(item) ⇒ Boolean
33 34 35 |
# File 'lib/simple_navigation/renderer/base.rb', line 33 def (item) (item) && (item) end |
#level ⇒ Object
25 26 27 |
# File 'lib/simple_navigation/renderer/base.rb', line 25 def level [:level] || :all end |
#render(item_container) ⇒ Object
Renders the specified ItemContainer to HTML.
When implementing a renderer, please consider to call include_sub_navigation? to determine whether an item’s sub_navigation should be rendered or not.
46 47 48 |
# File 'lib/simple_navigation/renderer/base.rb', line 46 def render(item_container) fail NotImplementedError, 'subclass responsibility' end |
#render_sub_navigation_for(item) ⇒ Object
37 38 39 |
# File 'lib/simple_navigation/renderer/base.rb', line 37 def (item) item..render() end |
#skip_if_empty? ⇒ Boolean
29 30 31 |
# File 'lib/simple_navigation/renderer/base.rb', line 29 def skip_if_empty? !![:skip_if_empty] end |