Class: Decidim::Problems::ProblemPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Problems::ProblemPresenter
- Includes:
- ActionView::Helpers::UrlHelper, SanitizeHelper, TranslatableAttributes
- Defined in:
- app/presenters/decidim/problems/problem_presenter.rb
Overview
Decorator for problem
Instance Method Summary collapse
-
#description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the problem description.
- #display_mention ⇒ Object
- #id_and_title(links: false, extras: true, html_escape: false) ⇒ Object
- #problem ⇒ Object
- #problem_path ⇒ Object
- #resource_manifest ⇒ Object
-
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the problem title.
Instance Method Details
#description(links: false, extras: true, strip_tags: false) ⇒ Object
Render the problem description
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 50 def description(links: false, extras: true, strip_tags: false) text = translated_attribute(problem.description) text = (sanitize_text(text)) if renderer = Decidim::ContentRenderers::HashtagRenderer.new(text) text = renderer.render(links:, extras:).html_safe text = Decidim::ContentRenderers::LinkRenderer.new(text).render if links text end |
#display_mention ⇒ Object
22 23 24 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 22 def display_mention link_to title, problem_path end |
#id_and_title(links: false, extras: true, html_escape: false) ⇒ Object
40 41 42 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 40 def id_and_title(links: false, extras: true, html_escape: false) "##{problem.id} - #{title(links:, extras:, html_escape:)}" end |
#problem ⇒ Object
14 15 16 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 14 def problem __getobj__ end |
#problem_path ⇒ Object
18 19 20 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 18 def problem_path Decidim::ResourceLocatorPresenter.new(problem).path end |
#resource_manifest ⇒ Object
64 65 66 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 64 def resource_manifest problem.class.resource_manifest end |
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the problem title
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
32 33 34 35 36 37 38 |
# File 'app/presenters/decidim/problems/problem_presenter.rb', line 32 def title(links: false, extras: true, html_escape: false) text = translated_attribute(problem.title) text = decidim_html_escape(text) if html_escape renderer = Decidim::ContentRenderers::HashtagRenderer.new(text) renderer.render(links:, extras:).html_safe end |