Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e6090e71
Commit
e6090e71
authored
Sep 03, 2019
by
jakeburden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for the passing of options to external_link
parent
90dc19e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
app/helpers/external_link_helper.rb
app/helpers/external_link_helper.rb
+2
-2
spec/helpers/external_link_helper_spec.rb
spec/helpers/external_link_helper_spec.rb
+5
-0
No files found.
app/helpers/external_link_helper.rb
View file @
e6090e71
# frozen_string_literal: true
# frozen_string_literal: true
module
ExternalLinkHelper
module
ExternalLinkHelper
def
external_link
(
body
,
url
)
def
external_link
(
body
,
url
,
options
=
{}
)
link_to
url
,
target:
'_blank'
,
rel:
'noopener noreferrer'
do
link_to
url
,
{
target:
'_blank'
,
rel:
'noopener noreferrer'
}.
merge
(
options
)
do
"
#{
body
}
#{
icon
(
'external-link'
)
}
"
.
html_safe
"
#{
body
}
#{
icon
(
'external-link'
)
}
"
.
html_safe
end
end
end
end
...
...
spec/helpers/external_link_helper_spec.rb
View file @
e6090e71
...
@@ -9,4 +9,9 @@ describe ExternalLinkHelper do
...
@@ -9,4 +9,9 @@ describe ExternalLinkHelper do
expect
(
external_link
(
'https://gitlab.com'
,
'https://gitlab.com'
).
to_s
)
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>'
)
.
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
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment