https://github.com/guillaumebriday/external_link_to
Rails link_to wrapper for external links.
https://github.com/guillaumebriday/external_link_to
gem helpers links rails rails-helper-tag ruby ruby-on-rails
Last synced: 10 months ago
JSON representation
Rails link_to wrapper for external links.
- Host: GitHub
- URL: https://github.com/guillaumebriday/external_link_to
- Owner: guillaumebriday
- License: mit
- Created: 2020-07-01T07:47:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-09T14:21:57.000Z (about 5 years ago)
- Last Synced: 2025-08-09T20:29:45.936Z (11 months ago)
- Topics: gem, helpers, links, rails, rails-helper-tag, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 21.5 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://www.paypal.me/guillaumebriday)


[](https://rubygems.org/gems/external_link_to)
[](https://rubygems.org/gems/external_link_to)
[](https://github.com/guillaumebriday/external_link_to)
# external_link_to
This gem provides a wrapper around the built in `ActionView::Helpers::UrlHelper#link_to` method available in Rails.
It creates a link tag with `target="_blank"` and `rel="noopener noreferrer"` attributes by default. Simple as that.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'external_link_to'
```
And then execute:
```bash
$ bundle
```
## Usage
For instance, this link:
```ruby
link_to 'Home', root_path, rel: 'noopener noreferrer', target: '_blank'
# => HomeHome
```
is exactly the same as:
```ruby
external_link_to 'Home', root_path
# => HomeHome
```
Basicaly, if you want to open a link in a new tab, just replace `link_to` with `external_link_to`:
```diff
- link_to 'Home', root_path
+ external_link_to 'Home', root_path
```
## Contributing
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).