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 +4 -4
- data/app/models/govuk_publishing_components/component_example.rb +7 -1
- data/app/views/govuk_publishing_components/component_guide/component_doc/_call.html.erb +10 -1
- data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb +8 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b6ae834bed9384ad7d843714779f18da3bc33f
|
4
|
+
data.tar.gz: 1cce5b18fccb49a006bb5b926caea9f58c11ea61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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>
|
data/app/views/govuk_publishing_components/component_guide/component_doc/_component.html.erb
CHANGED
@@ -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
|
-
|
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>
|