Class: Decidim::ResourcePresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::ResourcePresenter
- Includes:
- SanitizeHelper, TranslatableAttributes
- Defined in:
- app/presenters/decidim/resource_presenter.rb
Overview
A presenter to render attributes for resources
Instance Method Summary collapse
- #handle_locales(content, all_locales, &block) ⇒ Object
- #title(resource_title, links, html_escape, all_locales, extras: true) ⇒ Object
Methods included from SanitizeHelper
#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included
Methods included from TranslatableAttributes
Instance Method Details
#handle_locales(content, all_locales, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/presenters/decidim/resource_presenter.rb', line 18 def handle_locales(content, all_locales, &block) if all_locales content.each_with_object({}) do |(key, value), parsed_content| parsed_content[key] = if key == "machine_translations" handle_locales(value, all_locales, &block) else block.call(value) end end else yield(translated_attribute(content)) end end |
#title(resource_title, links, html_escape, all_locales, extras: true) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/presenters/decidim/resource_presenter.rb', line 9 def title(resource_title, links, html_escape, all_locales, extras: true) handle_locales(resource_title, all_locales) do |content| content = decidim_html_escape(content) if html_escape renderer = Decidim::ContentRenderers::HashtagRenderer.new(content) renderer.render(links: links, extras: extras).html_safe end end |