Sha256: e2f214ba507a90c64a16814553d1188fc4e7bb1487314e8350ede390dacf6797
Contents?: true
Size: 1.07 KB
Versions: 30
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Decidim # A presenter to render attributes for resources class ResourcePresenter < SimpleDelegator include Decidim::TranslatableAttributes include Decidim::SanitizeHelper 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 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 end end
Version data entries
30 entries across 30 versions & 1 rubygems