Allow for the passing of options to external_link
This commit is contained in:
parent
90dc19e9f0
commit
e6090e713b
2 changed files with 7 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ExternalLinkHelper
|
||||
def external_link(body, url)
|
||||
link_to url, target: '_blank', rel: 'noopener noreferrer' do
|
||||
def external_link(body, url, options = {})
|
||||
link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
|
||||
"#{body} #{icon('external-link')}".html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,4 +9,9 @@ describe ExternalLinkHelper do
|
|||
expect(external_link('https://gitlab.com', 'https://gitlab.com').to_s)
|
||||
.to eq('<a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
|
||||
end
|
||||
|
||||
it 'allows options when creating external link with icon' do
|
||||
expect(external_link('https://gitlab.com', 'https://gitlab.com', { "data-foo": "bar", class: "externalLink" }).to_s)
|
||||
.to eq('<a target="_blank" rel="noopener noreferrer" data-foo="bar" class="externalLink" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue