Class: Decidim::ContentRenderers::MentionResourceRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Decidim::ContentRenderers::MentionResourceRenderer
- Includes:
- ActionView::Helpers::UrlHelper, SanitizeHelper
- Defined in:
- decidim-core/lib/decidim/content_renderers/mention_resource_renderer.rb
Overview
A renderer that searches Global IDs representing resources in content and replaces it with a link to the resource.
e.g. gid://<APP_NAME>/Decidim::Proposals::Proposal/1
Constant Summary collapse
- GLOBAL_ID_REGEX =
Matches a global id representing a Decidim::Proposals::Proposal
%r{gid://[\w-]+/Decidim::Proposals::Proposal/\d+}
Instance Attribute Summary
Attributes inherited from BaseRenderer
Instance Method Summary collapse
-
#render(editor: false, **_) ⇒ String
Replaces found Global IDs matching an existing proposal with a link to the resource.
Methods included from SanitizeHelper
#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
Methods inherited from BaseRenderer
Methods included from Decidim::ContentProcessor::Common
#html_content?, #html_fragment
Constructor Details
This class inherits a constructor from Decidim::ContentRenderers::BaseRenderer
Instance Method Details
#render(editor: false, **_) ⇒ String
Replaces found Global IDs matching an existing proposal with a link to the resource.
23 24 25 |
# File 'decidim-core/lib/decidim/content_renderers/mention_resource_renderer.rb', line 23 def render(editor: false, **_) replace_pattern(content, GLOBAL_ID_REGEX, editor:) end |