content_block_tools 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/components/content_block_tools/base_component.rb +1 -0
- data/app/components/content_block_tools/contact_component.html.erb +2 -2
- data/app/components/content_block_tools/contact_component.rb +2 -4
- data/app/components/content_block_tools/contacts/address_component.rb +0 -2
- data/app/components/content_block_tools/contacts/contact_link_component.rb +0 -2
- data/app/components/content_block_tools/contacts/email_address_component.rb +0 -2
- data/app/components/content_block_tools/contacts/telephone_component.rb +0 -2
- data/lib/content_block_tools/content_block.rb +4 -1
- data/lib/content_block_tools/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6b4006445fa5c5a11bf7f14e6ccfcd1819a9bc043af6f3ad19a56334d54172
|
4
|
+
data.tar.gz: 8c513039b815152a5a3bdb0171dc89e4ec6934068ebc46c25c93d64801943d1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c96843959e74701746dc5aa20e8b605ad811c810b703f55d6d2cd3ad84a5c17c43bfefe741a5099fedc31f3a67480ee3c4e1d9d8a0ef24d9d4fe4f9ea3eec54
|
7
|
+
data.tar.gz: d7a5a5463e75a58b615fa680e4f0ef264d95e1b5c14c2474b40fdc2e61c9bcb01064052cbcf70461968c059206b3fb288ea658328b9554bd3a15e002e17283a9
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<div class="vcard">
|
2
2
|
<p class="fn org content-block__title"><%= content_block.title %></p>
|
3
3
|
|
4
|
-
<% if block_type.present? && content_block.details[:description] %>
|
4
|
+
<% if !block_type.present? && content_block.details[:description] %>
|
5
5
|
<%= render_govspeak(content_block.details[:description]) %>
|
6
6
|
<% end %>
|
7
7
|
|
8
8
|
<% if block_type.nil? %>
|
9
9
|
<% BLOCK_TYPES.each do |block_type| %>
|
10
|
-
<%
|
10
|
+
<% content_for_block_type(block_type).each do |item| %>
|
11
11
|
<p class="content-block__subtitle"><%= item[:title] %></p>
|
12
12
|
<%= component_for_block_type(block_type).new(item:).render.html_safe %>
|
13
13
|
<% end %>
|
@@ -16,10 +16,8 @@ module ContentBlockTools
|
|
16
16
|
"ContentBlockTools::Contacts::#{block_type.to_s.singularize.camelize}Component".constantize
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
[key, content_block.details[key]&.values]
|
22
|
-
}.to_h
|
19
|
+
def content_for_block_type(block_type)
|
20
|
+
content_block.details.fetch(block_type, {}).values
|
23
21
|
end
|
24
22
|
|
25
23
|
def item_to_render
|
@@ -40,6 +40,7 @@ module ContentBlockTools
|
|
40
40
|
# @return [String]
|
41
41
|
class ContentBlock
|
42
42
|
include ActionView::Helpers::TagHelper
|
43
|
+
class UnknownComponentError < StandardError; end
|
43
44
|
|
44
45
|
CONTENT_BLOCK_PREFIX = "content_block_".freeze
|
45
46
|
|
@@ -87,7 +88,7 @@ module ContentBlockTools
|
|
87
88
|
|
88
89
|
def content
|
89
90
|
field_names.present? ? field_or_block_content : component.new(content_block: self).render
|
90
|
-
rescue
|
91
|
+
rescue UnknownComponentError
|
91
92
|
title
|
92
93
|
end
|
93
94
|
|
@@ -110,6 +111,8 @@ module ContentBlockTools
|
|
110
111
|
|
111
112
|
def component
|
112
113
|
"ContentBlockTools::#{document_type.camelize}Component".constantize
|
114
|
+
rescue NameError
|
115
|
+
raise UnknownComponentError
|
113
116
|
end
|
114
117
|
|
115
118
|
def field_presenter(field)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: content_block_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -65,6 +65,20 @@ dependencies:
|
|
65
65
|
- - '='
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: 5.1.18
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: simplecov
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
68
82
|
- !ruby/object:Gem::Dependency
|
69
83
|
name: actionview
|
70
84
|
requirement: !ruby/object:Gem::Requirement
|