Class: ContentBlockTools::Presenters::BlockPresenters::Contact::EmailAddressPresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
BlockLevelContactItem
Defined in:
lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb

Constant Summary

Constants included from BlockLevelContactItem

BlockLevelContactItem::BASE_TAG_TYPE

Constants inherited from BasePresenter

BasePresenter::BASE_TAG_TYPE

Instance Attribute Summary

Attributes inherited from BasePresenter

#item

Instance Method Summary collapse

Methods included from BlockLevelContactItem

#initialize, #title, #wrapper

Methods inherited from BasePresenter

#initialize

Methods included from Govspeak

#render_govspeak

Instance Method Details

#descriptionObject



41
42
43
44
45
# File 'lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb', line 41

def description
  (:li) do
    render_govspeak(item[:description])
  end
end

#emailObject



19
20
21
22
23
24
25
26
# File 'lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb', line 19

def email
  (:li) do
    concat (:a,
                       link_text,
                       class: "email content-block__link",
                       href: "mailto:#{item[:email_address]}#{query_params}")
  end
end


37
38
39
# File 'lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb', line 37

def link_text
  item[:label] || item[:email_address]
end

#query_paramsObject



28
29
30
31
32
33
34
35
# File 'lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb', line 28

def query_params
  params = {
    subject: item[:subject],
    body: item[:body],
  }.compact.map { |k, v| "#{k}=#{v}" }.join("&")

  "?#{params}" if params.present?
end

#renderObject



10
11
12
13
14
15
16
17
# File 'lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb', line 10

def render
  wrapper do
    (:ul, class: "content-block__list") do
      concat email
      concat description if item[:description].present?
    end
  end
end