Class: Hensel::Builder::Item
- Extended by:
- Forwardable
- Defined in:
- lib/hensel/builder/item.rb
Constant Summary
Constants included from Helpers::TagHelpers
Helpers::TagHelpers::BOOLEAN_ATTRIBUTES, Helpers::TagHelpers::ESCAPE_REGEXP, Helpers::TagHelpers::ESCAPE_VALUES
Instance Attribute Summary collapse
-
#is_first ⇒ Object
Returns the value of attribute is_first.
-
#is_last ⇒ Object
Returns the value of attribute is_last.
-
#options ⇒ Object
Returns the value of attribute options.
-
#renderer ⇒ Object
Returns the value of attribute renderer.
-
#text ⇒ Object
Returns the value of attribute text.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from Node
#attributes, #content, #indent, #name, #parent
Instance Method Summary collapse
- #first? ⇒ Boolean
-
#initialize(text, url, **options) ⇒ Item
constructor
A new instance of Item.
- #last? ⇒ Boolean
- #render ⇒ Object
Methods inherited from Node
Methods included from Helpers::TagHelpers
#append_attribute, #content_tag, #tag
Constructor Details
#initialize(text, url, **options) ⇒ Item
Returns a new instance of Item.
14 15 16 17 18 |
# File 'lib/hensel/builder/item.rb', line 14 def initialize(text, url, **) @text = h(text) @url = url @options = Hensel.configuration..merge() end |
Instance Attribute Details
#is_first ⇒ Object
Returns the value of attribute is_first.
10 11 12 |
# File 'lib/hensel/builder/item.rb', line 10 def is_first @is_first end |
#is_last ⇒ Object
Returns the value of attribute is_last.
10 11 12 |
# File 'lib/hensel/builder/item.rb', line 10 def is_last @is_last end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/hensel/builder/item.rb', line 9 def @options end |
#renderer ⇒ Object
Returns the value of attribute renderer.
10 11 12 |
# File 'lib/hensel/builder/item.rb', line 10 def renderer @renderer end |
#text ⇒ Object
Returns the value of attribute text.
9 10 11 |
# File 'lib/hensel/builder/item.rb', line 9 def text @text end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/hensel/builder/item.rb', line 9 def url @url end |
Instance Method Details
#first? ⇒ Boolean
34 35 36 |
# File 'lib/hensel/builder/item.rb', line 34 def first? !!is_first end |
#last? ⇒ Boolean
38 39 40 |
# File 'lib/hensel/builder/item.rb', line 38 def last? !!is_last end |
#render ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hensel/builder/item.rb', line 20 def render if renderer instance_eval(&renderer) else node(:li, **) do if !Hensel.configuration.last_item_link? && item.last? node(:span){ item.text } else node(:a, href: item.url){ item.text } end end end end |