Module: Katalyst::Navigation::HasLink

Extended by:
ActiveSupport::Concern
Included in:
Button, Link
Defined in:
app/models/concerns/katalyst/navigation/has_link.rb

Constant Summary collapse

HTTP_METHODS =
%w[get post patch put delete].index_by(&:itself).freeze
TARGETS =
%w[self top blank kpop].index_by(&:itself).freeze

Instance Method Summary collapse

Instance Method Details



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/concerns/katalyst/navigation/has_link.rb', line 29

def link_attributes
  options = if target_self?
              {} # default
            elsif target_blank? || target_top?
              { target: "_#{target}" } # browser will handle this target
            else
              { data: { turbo_frame: target } } # turbo target
            end

  options.deep_merge!({ data: { turbo_method: http_method } }) unless http_get? || target_blank?

  options
end