8000 make for=outer in tab optional · sbadithe/docs.scala-lang@8270b42 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8270b42

Browse files
committed
make for=outer in tab optional
1 parent 0240616 commit 8270b42

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,17 @@ def render(context)
9292
class TabBlock < Liquid::Block
9393
alias_method :render_block, :render
9494

95-
SYNTAX = /^\s*(#{Liquid::QuotedFragment})\s+(?:for=(#{Liquid::QuotedFragment}))(?:\s+(defaultTab))?/o
95+
SYNTAX = /^\s*(#{Liquid::QuotedFragment})\s+(?:for=(#{Liquid::QuotedFragment}))?(?:\s+(defaultTab))?/o
9696
Syntax = SYNTAX
9797

9898
def initialize(block_name, markup, tokens)
9999
super
100100

101101
if markup =~ SYNTAX
102102
@tab = Tabs::unquote($1)
103-
@name = Tabs::unquote($2)
103+
if $2
104+
@name = Tabs::unquote($2)
105+
end
104106
@anchor = Tabs::asAnchor(@tab)
105107
if $3
106108
@defaultTab = true
@@ -122,6 +124,10 @@ def render(context)
122124
if tab_env.nil?
123125
raise SyntaxError.new("Tab block '#{tabcontent.label}' must be inside a tabs block")
124126
end
127+
if !@name.nil? && tab_env != @name
128+
raise SyntaxError.new(
129+
"Tab block '#{@tab}' for=#{@name} does not match its enclosing tabs block #{tab_env}")
130+
end
125131
environment["tabs-#{tab_env}"] ||= []
126132
environment["tabs-#{tab_env}"] << tabcontent
127133
end

0 commit comments

Comments
 (0)
0