Skip to content

Commit 37f7c57

Browse files
Revert to initial commit's global approach for tab default selection
Co-authored-by: harikrishnan83 <126087+harikrishnan83@users.noreply.github.com>
1 parent 86c4bcf commit 37f7c57

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

_plugins/_jekyll-tabs-specmatic.erb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<div class="tab-wrapper">
22
<ul class="tab">
3-
<%
4-
tabs = environment["tabs-#{@name}"]
5-
default_index = 0
6-
if @default_tab
7-
default_index = tabs.keys.find_index(@default_tab) || 0
8-
end
9-
%>
10-
<% tabs.each_with_index do |(key, value), index| %>
11-
<li <%= index == default_index ? ' class="active"' : ''%>>
3+
<% sorted_tabs = environment["tabs-#{@name}"].sort_by { |key, value| key.include?('specmatic.yaml') ? 0 : 1 } %>
4+
<% sorted_tabs.each_with_index do |(key, value), index| %>
5+
<li <%= index == 0 ? ' class="active"' : ''%>>
126
<button class="tab-click" data-tab-content-selector="<%= uuid %>-<%= @name %>-<%= key %>"><%= key %></button>
137
</li>
148
<% end %>
159
</ul>
1610

1711
<ul class="tab-content">
18-
<% tabs.each_with_index do |(key, value), index| %>
19-
<li <%= index == default_index ? ' class="active"' : ''%> data-tab-content-id="<%= uuid %>-<%= @name %>-<%= key %>"><%= value %></li>
12+
<% sorted_tabs.each_with_index do |(key, value), index| %>
13+
<li <%= index == 0 ? ' class="active"' : ''%> data-tab-content-id="<%= uuid %>-<%= @name %>-<%= key %>"><%= value %></li>
2014
<% end %>
2115
</ul>
2216
</div>

_plugins/jekyll-tabs-specmatic.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,7 @@ def initialize(block_name, markup, tokens)
1818
if markup == ''
1919
raise SyntaxError.new("Block #{block_name} requires 1 attribute")
2020
end
21-
22-
# Parse markup to extract name and optional default parameter
23-
# Format: "name" or "name default:tab_name"
24-
parts = markup.strip.split(' ', 2)
25-
@name = sanitizeName(parts[0])
26-
@default_tab = nil
27-
28-
if parts.length > 1 && parts[1].start_with?('default:')
29-
@default_tab = parts[1].sub('default:', '').strip
30-
end
21+
@name = sanitizeName(markup)
3122

3223
end
3324

documentation/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ contracts:
190190

191191
The `startTimeoutInMilliseconds` setting in Specmatic ensures that a stub service, whether started via the _stub command_ or programmatically using _createStub_ exits if it doesn't start within the defined time.
192192

193-
{% tabs stubTimeout default:specmatic.yaml %}
193+
{% tabs stubTimeout %}
194194
{% tab stubTimeout specmatic.json %}
195195
```json
196196
{

documentation/contract_tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ So instead:
355355

356356
* Create a file named specmatic.json OR specmatic.yaml OR specmatic.yml which contains the Specmatic configuration.
357357

358-
{% tabs config_contractTests default:specmatic.yaml %}
358+
{% tabs config_contractTests %}
359359
{% tab config_contractTests specmatic.yaml %}
360360
```yaml
361361
version: 2

0 commit comments

Comments
 (0)