Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions _plugins/_jekyll-tabs-specmatic.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<div class="tab-wrapper">
<ul class="tab">
<% environment["tabs-#{@name}"].each_with_index do |(key, value), index| %>
<li <%= index == 0 ? ' class="active"' : ''%>>
<%
tabs = environment["tabs-#{@name}"]
default_index = 0
if @default_tab
default_index = tabs.keys.find_index(@default_tab) || 0
end
%>
<% tabs.each_with_index do |(key, value), index| %>
<li <%= index == default_index ? ' class="active"' : ''%>>
<button class="tab-click" data-tab-content-selector="<%= uuid %>-<%= @name %>-<%= key %>"><%= key %></button>
</li>
<% end %>
</ul>

<ul class="tab-content">
<% environment["tabs-#{@name}"].each_with_index do |(key, value), index| %>
<li <%= index == 0 ? ' class="active"' : ''%> data-tab-content-id="<%= uuid %>-<%= @name %>-<%= key %>"><%= value %></li>
<% tabs.each_with_index do |(key, value), index| %>
<li <%= index == default_index ? ' class="active"' : ''%> data-tab-content-id="<%= uuid %>-<%= @name %>-<%= key %>"><%= value %></li>
<% end %>
</ul>
</div>
11 changes: 10 additions & 1 deletion _plugins/jekyll-tabs-specmatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ def initialize(block_name, markup, tokens)
if markup == ''
raise SyntaxError.new("Block #{block_name} requires 1 attribute")
end
@name = sanitizeName(markup)

# Parse markup to extract name and optional default parameter
# Format: "name" or "name default:tab_name"
parts = markup.strip.split(' ', 2)
@name = sanitizeName(parts[0])
@default_tab = nil

if parts.length > 1 && parts[1].start_with?('default:')
@default_tab = parts[1].sub('default:', '').strip
end

end

Expand Down
2 changes: 1 addition & 1 deletion documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ contracts:

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.

{% tabs stubTimeout %}
{% tabs stubTimeout default:specmatic.yaml %}
{% tab stubTimeout specmatic.json %}
```json
{
Expand Down
2 changes: 1 addition & 1 deletion documentation/contract_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ So instead:

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

{% tabs config_contractTests %}
{% tabs config_contractTests default:specmatic.yaml %}
{% tab config_contractTests specmatic.yaml %}
```yaml
version: 2
Expand Down