Class: TextHelpers::ExternalLinks
- Inherits:
-
Redcarpet::Render::HTML
- Object
- Redcarpet::Render::HTML
- TextHelpers::ExternalLinks
- Defined in:
- lib/text_helpers/translation.rb
Constant Summary collapse
- PROTOCOL_MATCHER =
/\Ahttp/.freeze
Instance Method Summary collapse
Instance Method Details
#link(link, title, content) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/text_helpers/translation.rb', line 11 def link(link, title, content) attributes = [ ("href=\"#{link}\"" if link), ("title=\"#{title}\"" if title), ("target=\"_blank\" rel=\"noopener\"" if link.match?(PROTOCOL_MATCHER)), ] "<a #{attributes.compact.join(" ")}>#{content}</a>" end |