Class: Layered::Ui::TagHelper::TagBuilder
- Inherits:
-
Object
- Object
- Layered::Ui::TagHelper::TagBuilder
- Defined in:
- app/helpers/layered/ui/tag_helper.rb
Instance Attribute Summary collapse
-
#popover_align ⇒ Object
readonly
Returns the value of attribute popover_align.
-
#popover_body ⇒ Object
readonly
Returns the value of attribute popover_body.
-
#popover_id ⇒ Object
readonly
Returns the value of attribute popover_id.
-
#popover_open ⇒ Object
readonly
Returns the value of attribute popover_open.
-
#popover_placement ⇒ Object
readonly
Returns the value of attribute popover_placement.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #button(**options, &block) ⇒ Object
-
#initialize(view) ⇒ TagBuilder
constructor
A new instance of TagBuilder.
- #link(url, **options, &block) ⇒ Object
- #popover(id: nil, placement: :bottom, align: :start, open: false, &block) ⇒ Object
- #popover? ⇒ Boolean
- #remove(url = nil, **options, &block) ⇒ Object
- #text(content = nil, **options, &block) ⇒ Object
Constructor Details
#initialize(view) ⇒ TagBuilder
Returns a new instance of TagBuilder.
76 77 78 79 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 76 def initialize(view) @view = view @segments = [] end |
Instance Attribute Details
#popover_align ⇒ Object (readonly)
Returns the value of attribute popover_align.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def popover_align @popover_align end |
#popover_body ⇒ Object (readonly)
Returns the value of attribute popover_body.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def popover_body @popover_body end |
#popover_id ⇒ Object (readonly)
Returns the value of attribute popover_id.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def popover_id @popover_id end |
#popover_open ⇒ Object (readonly)
Returns the value of attribute popover_open.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def popover_open @popover_open end |
#popover_placement ⇒ Object (readonly)
Returns the value of attribute popover_placement.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def popover_placement @popover_placement end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
74 75 76 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 74 def segments @segments end |
Instance Method Details
#button(**options, &block) ⇒ Object
87 88 89 90 91 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 87 def (**, &block) content = block ? @view.capture(&block) : nil @segments << { kind: :button, content: content, options: } nil end |
#link(url, **options, &block) ⇒ Object
93 94 95 96 97 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 93 def link(url, **, &block) content = block ? @view.capture(&block) : nil @segments << { kind: :link, url: url, content: content, options: } nil end |
#popover(id: nil, placement: :bottom, align: :start, open: false, &block) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 105 def popover(id: nil, placement: :bottom, align: :start, open: false, &block) @popover_id = id || "l-ui-tag-popover-#{SecureRandom.hex(4)}" @popover_placement = placement @popover_align = align @popover_open = open @popover_body = @view.capture(&block) nil end |
#popover? ⇒ Boolean
114 115 116 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 114 def popover? !@popover_id.nil? end |
#remove(url = nil, **options, &block) ⇒ Object
99 100 101 102 103 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 99 def remove(url = nil, **, &block) content = block ? @view.capture(&block) : nil @segments << { kind: :remove, url: url, content: content, options: } nil end |
#text(content = nil, **options, &block) ⇒ Object
81 82 83 84 85 |
# File 'app/helpers/layered/ui/tag_helper.rb', line 81 def text(content = nil, **, &block) content = @view.capture(&block) if block @segments << { kind: :text, content: content, options: } nil end |