Class: ContentBlockTools::Presenters::BlockPresenters::Contact::AddressPresenter
Constant Summary
BlockLevelContactItem::BASE_TAG_TYPE
BasePresenter::BASE_TAG_TYPE
Instance Attribute Summary
#item
Instance Method Summary
collapse
#initialize, #title, #wrapper
#initialize
Methods included from Govspeak
#render_govspeak
Instance Method Details
#class_for_field_name(field_name) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb', line 28
def class_for_field_name(field_name)
{
recipient: "organization-name",
street_address: "street-address",
town_or_city: "locality",
state_or_county: "region",
postal_code: "postal-code",
country: "country-name",
}[field_name]
end
|
#render ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb', line 10
def render
wrapper do
output = []
output << content_tag(:p, class: "adr content-block__body") do
%i[recipient street_address town_or_city state_or_county postal_code country].map { |field|
next if item[field].blank?
content_tag(:span, item[field], { class: class_for_field_name(field) })
}.compact_blank.join(",<br/>").html_safe
end
output << render_govspeak(item[:description]) if item[:description].present?
output.join.html_safe
end
end
|