govuk_publishing_components 3.0.3 → 3.1.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
  SHA1:
3
- metadata.gz: 6217499ae86d9a29e7d70a71d439797fb8c4420a
4
- data.tar.gz: af58a7d34a1d5261477e08ed3345db245eaa98e9
3
+ metadata.gz: 82b6ae834bed9384ad7d843714779f18da3bc33f
4
+ data.tar.gz: 1cce5b18fccb49a006bb5b926caea9f58c11ea61
5
5
  SHA512:
6
- metadata.gz: 2377a280243b42cfa9eb4ebd21f80633a7c0a2f29a105c383d597094bec2badadfe17f7b138e647df634d52f60302efc550b5bbc83c0f662ca2afe7d77349887
7
- data.tar.gz: 96a892098207b0a12feeaed47a0c7188e445d6aa12138d4e811e89c14cc7148a88d6c3938370b92f9f0b6bc74d1c0a2267c98b1960f2e6f6fa11f9c2f8bc6d7b
6
+ metadata.gz: 6d39943296c9516ff5d8516dfc369c771aa8f63bf613a77b9878a0ce1a180107b6b02b88c7341c301bad66e39ee63786e5292b5c7ce8f924d280f22050cd4a8d
7
+ data.tar.gz: 8179f295877a4303ae850b2c81ec75eac6cdb82ecae7bb85927c7ba4905fbcf6dcc2b5bcfa2deef6ee31bf2c9de72a35d3351ae81fb3e4de72971eaf62d6f740
@@ -5,13 +5,15 @@ module GovukPublishingComponents
5
5
  attr_reader :id,
6
6
  :data,
7
7
  :context,
8
- :description
8
+ :description,
9
+ :block
9
10
 
10
11
  def initialize(id, data, context, description)
11
12
  @id = id
12
13
  @data = data || {}
13
14
  @context = context || {}
14
15
  @description = description || false
16
+ @block = @data.delete(:block) || false
15
17
  end
16
18
 
17
19
  def name
@@ -67,6 +69,10 @@ module GovukPublishingComponents
67
69
  govspeak_to_html(description) if description.present?
68
70
  end
69
71
 
72
+ def has_block?
73
+ !!block
74
+ end
75
+
70
76
  private
71
77
 
72
78
  def govspeak_to_html(govspeak)
@@ -1,3 +1,12 @@
1
1
  <div class="component-call component-highlight" contenteditable>
2
- <pre><code><%= example.highlight_code("\<%= render \"#{@component_doc.partial_path}\", #{example.pretty_data} %\>") %></code></pre>
2
+ <% if example.has_block? %>
3
+ <%
4
+ code = "<%= render \"#{@component_doc.partial_path}\", #{example.pretty_data} do %\>\n"
5
+ code += " #{example.block.html_safe}"
6
+ code += "<% end %\>"
7
+ -%>
8
+ <pre><code><%= example.highlight_code(code) %></code></pre>
9
+ <% else %>
10
+ <pre><code><%= example.highlight_code("\<%= render \"#{@component_doc.partial_path}\", #{example.pretty_data} %\>") %></code></pre>
11
+ <% end %>
3
12
  </div>
@@ -2,5 +2,12 @@
2
2
  <% if example.right_to_left? %>direction-rtl<% end %>
3
3
  <% if example.dark_background? %>dark-background<% end %>
4
4
  <% if preview_page %>component-guide-preview--simple<% end %>" data-content="EXAMPLE">
5
- <%= render component_doc.partial_path, example.html_safe_data %>
5
+
6
+ <% if example.has_block? %>
7
+ <%= render component_doc.partial_path, example.html_safe_data do %>
8
+ <%= example.block.html_safe %>
9
+ <% end %>
10
+ <% else %>
11
+ <%= render component_doc.partial_path, example.html_safe_data %>
12
+ <% end %>
6
13
  </div>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '3.0.3'.freeze
2
+ VERSION = '3.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev