Module: NitroKit::ButtonHelper
- Includes:
- Variants
- Defined in:
- app/helpers/nitro_kit/button_helper.rb
Instance Method Summary collapse
- #nk_button(text = nil, **attrs, &block) ⇒ Object
- #nk_button_group(**attrs, &block) ⇒ Object
-
#nk_button_link_to(*args, **attrs, &block) ⇒ Object
Matches the API of UrlHelper#link_to.
-
#nk_button_to(name = nil, url_for_options = nil, **attrs, &block) ⇒ Object
Matches the API of UrlHelper#button_to.
Methods included from Variants
Instance Method Details
#nk_button(text = nil, **attrs, &block) ⇒ Object
7 8 9 |
# File 'app/helpers/nitro_kit/button_helper.rb', line 7 def (text = nil, **attrs, &block) render(NitroKit::Button.from_template(text, **attrs), &block) end |
#nk_button_group(**attrs, &block) ⇒ Object
45 46 47 |
# File 'app/helpers/nitro_kit/button_helper.rb', line 45 def (**attrs, &block) render(ButtonGroup.from_template(**attrs), &block) end |
#nk_button_link_to(*args, **attrs, &block) ⇒ Object
Matches the API of UrlHelper#link_to
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/nitro_kit/button_helper.rb', line 28 def (*args, **attrs, &block) case args.length when 1 , text = args when 2 text, = args else raise ArgumentError, "1..2 arguments expected, got #{args.length}" end href = attrs[:href] || url_target(text, ) render(NitroKit::Button.from_template(text, **attrs, href:), &block) end |
#nk_button_to(name = nil, url_for_options = nil, **attrs, &block) ⇒ Object
Matches the API of UrlHelper#button_to
14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/nitro_kit/button_helper.rb', line 14 def (name = nil, = nil, **attrs, &block) = name if block_given? = attrs.delete(:form) || {} .merge!(attrs.slice(:multipart, :data, :method, :authenticity_token, :remote, :enforce_utf8)) form_tag(, ) do (name, type: "submit", **attrs, &block) end end |