class Decidim::ContentRenderers::LinkRenderer

A renderer that converts URLs to links and strips attributes in anchors.

Examples: `<a href=“urls.net” onmouseover=“alert('hello')”>URLs</a>` Gets rendered as: `<a href=“decidim.org” target=“_blank” rel=“noopener”>decidim.org>` And: `<a href=“javascript:document.cookies”>click me</a>` Gets rendered as: `click me`

@see BaseRenderer Examples of how to use a content renderer

Public Instance Methods

render(options = {}) click to toggle source

@return [String] the content ready to display (contains HTML)

# File lib/decidim/content_renderers/link_renderer.rb, line 19
def render(options = {})
  return content unless content.is_a?(String)

  options = { target: "_blank", rel: "nofollow noopener" }.merge(options)
  Anchored::Linker.auto_link(content, options)
end