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
22
23
24
25
26
27
28
29
30
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb', line 22
def class_for_field_name(field_name)
{
street_address: "street-address",
locality: "locality",
region: "region",
postal_code: "postal-code",
country: "country-name",
}[field_name]
end
|
#render ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb', line 10
def render
wrapper do
content_tag(:p, class: "adr") do
%i[street_address locality region 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
end
end
|