Class: Decidim::Proposals::ProposalPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Proposals::ProposalPresenter
- Includes:
- ActionView::Helpers::UrlHelper
- Defined in:
- app/presenters/decidim/proposals/proposal_presenter.rb
Overview
Decorator for proposals
Instance Method Summary collapse
- #author ⇒ Object
- #body(links: false, extras: true, strip_tags: false) ⇒ Object
- #display_mention ⇒ Object
- #proposal ⇒ Object
- #proposal_path ⇒ Object
-
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the proposal title.
Instance Method Details
#author ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 12 def @author ||= if official? Decidim::Proposals::OfficialAuthorPresenter.new else = .first if .user_group Decidim::UserGroupPresenter.new(.user_group) else Decidim::UserPresenter.new(.) end end end |
#body(links: false, extras: true, strip_tags: false) ⇒ Object
48 49 50 51 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 48 def body(links: false, extras: true, strip_tags: false) renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.body) renderer.render(links: links, extras: extras, strip_tags: ).html_safe end |
#display_mention ⇒ Object
33 34 35 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 33 def display_mention link_to title, proposal_path end |
#proposal ⇒ Object
25 26 27 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 25 def proposal __getobj__ end |
#proposal_path ⇒ Object
29 30 31 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 29 def proposal_path Decidim::ResourceLocatorPresenter.new(proposal).path end |
#title(links: false, extras: true, html_escape: false) ⇒ Object
Render the proposal title
links - should render hashtags as links? extras - should include extra hashtags?
Returns a String.
43 44 45 46 |
# File 'app/presenters/decidim/proposals/proposal_presenter.rb', line 43 def title(links: false, extras: true, html_escape: false) renderer = Decidim::ContentRenderers::HashtagRenderer.new(proposal.title) renderer.render(links: links, extras: extras, html_escape: html_escape).html_safe end |