Class: Decidim::ContentRenderers::LinkRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Decidim::ContentRenderers::LinkRenderer
- Defined in:
- lib/decidim/content_renderers/link_renderer.rb
Overview
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</a>` And: `<a href=“javascript:document.cookies”>click me</a>` Gets rendered as: `click me`
Instance Attribute Summary
Attributes inherited from BaseRenderer
Instance Method Summary collapse
-
#render(options = {}) ⇒ String
The content ready to display (contains HTML).
Methods inherited from BaseRenderer
Constructor Details
This class inherits a constructor from Decidim::ContentRenderers::BaseRenderer
Instance Method Details
#render(options = {}) ⇒ String
Returns the content ready to display (contains HTML).
19 20 21 22 23 24 |
# File 'lib/decidim/content_renderers/link_renderer.rb', line 19 def render( = {}) return content unless content.is_a?(String) = { target: "_blank", rel: "nofollow noopener" }.merge() Anchored::Linker.auto_link(content, ) end |