Module: RedminePluginKit::Helpers::GlobalHelper

Defined in:
lib/redmine_plugin_kit/helpers/global_helper.rb

Instance Method Summary collapse

Instance Method Details



6
7
8
9
10
11
12
# File 'lib/redmine_plugin_kit/helpers/global_helper.rb', line 6

def link_to_external(name, link, **options)
  options[:class] ||= 'external'
  options[:class] = "#{options[:class]} external" if options[:class].exclude? 'external'
  options[:rel] ||= 'noopener noreferrer'

  link_to name, link, **options
end


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/redmine_plugin_kit/helpers/global_helper.rb', line 14

def link_to_url(url, **options)
  return if url.blank?

  parts = url.split '://'
  name = if parts.count.positive?
           parts.shift
           parts.join.chomp '/'
         else
           url.chomp '/'
         end

  link_to_external name, url, **options
end