8000 do not repeat tabs name per tab · sbadithe/docs.scala-lang@0240616 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0240616

Browse files
committed
do not repeat tabs name per tab
1 parent 417389a commit 0240616

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

_plugins/jekyll-tabs-lib/jekyll-tabs-4scala.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ def initialize(block_name, markup, tokens)
4343
def render(context)
4444
environment = context.environments.first
4545
environment["tabs-#{@name}"] = [] # reset every time (so page translations can use the same name)
46-
super
47-
46+
if environment["CURRENT_TABS_ENV"].nil?
47+
environment["CURRENT_TABS_ENV"] = @name
48+
else
49+
raise SyntaxError.new("Nested tabs are not supported")
50+
end
51+
super # super call renders the internal content
52+
environment["CURRENT_TABS_ENV"] = nil # reset after rendering
4853
foundDefault = false
4954

5055
allTabs = environment["tabs-#{@name}"]
@@ -113,8 +118,12 @@ def render(context)
113118
content = converter.convert(pre_content)
114119
tabcontent = TabDetails.new(label: @tab, anchor: @anchor, defaultTab: @defaultTab, content: content)
115120
environment = context.environments.first
116-
environment["tabs-#{@name}"] ||= []
117-
environment["tabs-#{@name}"] << tabcontent
121+
tab_env = environment["CURRENT_TABS_ENV"]
122+
if tab_env.nil?
123+
raise SyntaxError.new("Tab block '#{tabcontent.label}' must be inside a tabs block")
124+
end
125+
environment["tabs-#{tab_env}"] ||= []
126+
environment["tabs-#{tab_env}"] << tabcontent
118127
end
119128
end
120129
end

0 commit comments

Comments
 (0)
0