content_block_tools 1.2.3 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44d961fe89c55bb59ab7f9a54012f00165467bdddf69dda17962c853f362edf8
4
- data.tar.gz: 488cc06945339f511e4711cf4073ac358d78fbd2c7bf5320f2c236654b6a560a
3
+ metadata.gz: 8e13e7bcfb74b6aa0fbb3f9ace4e01a2f12f3a3f762b0b35bbdef23f678569cf
4
+ data.tar.gz: e0c2c0c50b7753a6137edba4e80c257b2b62d1462aacf7d10400fec4ee69be8c
5
5
  SHA512:
6
- metadata.gz: daacacf2c3f43440738193c8005cdd2678c83291d426f0cfbb9cb7295fb0e2e855f684f6501389f108785638da87507874bad5fdbe2ad23754f7673f62fdfaf8
7
- data.tar.gz: 2f7cc32524ebabc7efe34e2b9d7e85304420c295053c94f9a1cab00d6ce51b8b0284f49978a0336f81739c520e711d7255ef28c574c92fb38fbeaa876bdbd6bb
6
+ metadata.gz: fb1e6e2c7c06330274db7e8fbddd1a8ea9a3812033edf6076db0336b1277984066bc05a692f68aa62bd5c68c3a252f551a009d0183e81664f14e8db0f78d60d0
7
+ data.tar.gz: c790411231a5c2ab85325a1f3d66fd247f5cd7b631180243a4b4f935ca1ab452441f218458e2d8a98837dbaaf22d5fdacc73ddb24623e822f292be9286e1079e
@@ -5,13 +5,11 @@
5
5
  <dd class="content-block__contact-value">
6
6
  <%= render_govspeak(content_block.details[:description]) if content_block.details[:description] %>
7
7
  <dl class="content-block__contact-list--nested">
8
- <% BLOCK_TYPES.each do |block_type| %>
9
- <% content_for_block_type(block_type).each do |item| %>
10
- <dt class="content-block__contact-key"><%= item[:title] %></dt>
11
- <dd class="content-block__contact-value">
12
- <%= component_for_block_type(block_type).new(item:).render.html_safe %>
13
- </dd>
14
- <% end %>
8
+ <% items.each do |block_type, _, item| %>
9
+ <dt class="content-block__contact-key"><%= item[:title] %></dt>
10
+ <dd class="content-block__contact-value">
11
+ <%= component_for_block_type(block_type).new(item:).render.html_safe %>
12
+ </dd>
15
13
  <% end %>
16
14
  </dl>
17
15
  </dd>
@@ -12,12 +12,20 @@ module ContentBlockTools
12
12
 
13
13
  attr_reader :content_block, :block_type, :block_name
14
14
 
15
- def component_for_block_type(block_type)
16
- "ContentBlockTools::Contacts::#{block_type.to_s.singularize.camelize}Component".constantize
15
+ def items
16
+ BLOCK_TYPES.each_with_object([]) { |block_type, items|
17
+ content_block.details.fetch(block_type, {}).each do |key, item|
18
+ items << [block_type, key, item]
19
+ end
20
+ }.sort_by { |block_type, key| order.find_index("#{block_type}.#{key}") || Float::INFINITY }
21
+ end
22
+
23
+ def order
24
+ @order ||= content_block.details[:order] || []
17
25
  end
18
26
 
19
- def content_for_block_type(block_type)
20
- content_block.details.fetch(block_type, {}).values
27
+ def component_for_block_type(block_type)
28
+ "ContentBlockTools::Contacts::#{block_type.to_s.singularize.camelize}Component".constantize
21
29
  end
22
30
 
23
31
  def item_to_render
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "1.2.3"
4
+ VERSION = "1.3.0"
5
5
  end
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.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev