Class: Decidim::ContentRenderers::UserRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Decidim::ContentRenderers::UserRenderer
- Defined in:
- lib/decidim/content_renderers/user_renderer.rb
Overview
A renderer that searches Global IDs representing users in content and replaces it with a link to their profile with the nickname.
e.g. gid://<APP_NAME>/Decidim::User/1
Direct Known Subclasses
Constant Summary collapse
- GLOBAL_ID_REGEX =
Matches a global id representing a Decidim::User
%r{gid://[\w-]+/Decidim::User/\d+}
Instance Attribute Summary
Attributes inherited from BaseRenderer
Instance Method Summary collapse
-
#render(editor: false, **_) ⇒ String
Replaces found Global IDs matching an existing user with a link to their profile.
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 user with a link to their profile. The Global IDs representing an invalid Decidim::User are replaced with an empty string.
20 21 22 |
# File 'lib/decidim/content_renderers/user_renderer.rb', line 20 def render(editor: false, **_) replace_pattern(content, GLOBAL_ID_REGEX, editor:) end |