Module: Booties::ButtonHelper
- Includes:
- Utils
- Defined in:
- app/helpers/booties/button_helper.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#btn_link_to(name_or_path, path = nil, context: :default, **opts, &block) ⇒ Object
Renders a link as a Bootstrap button.
Methods included from Utils
Instance Method Details
#btn_link_to(name_or_path, path = nil, context: :default, **opts, &block) ⇒ Object
Renders a link as a Bootstrap button. The default behavior is to add the .btn and btn-default classes to the rendered tag. The button context can be overridden to something other than .btn-default such as .btn-primary using the context
parameter. The name
, options
, html_options
, and block
paramters are passed through to #link_to.
If html_options
includes a :class
option, the classes will be merged with the required .btn classes.
Examples:
<%= btn_link_to 'View', thingies_path %>
<a href="/thingies" class="btn btn-default">View</a>
<%= btn_link_to 'Sign out', destroy_user_session_path, context: :danger, class: 'btn-xs', method: :delete %>
<a href="/users/sign_out" class="btn btn-danger btn-xs" data-method="delete">Sign out</a>
26 27 28 29 30 31 32 33 |
# File 'app/helpers/booties/button_helper.rb', line 26 def btn_link_to(name_or_path, path = nil, context: :default, **opts, &block) opts[:class] = merge_classes %W[btn btn-#{context}], opts[:class] if block_given? link_to name_or_path, opts, &block else link_to name_or_path, path, opts end end |