File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -92,15 +92,17 @@ def render(context)
92
92
class TabBlock < Liquid ::Block
93
93
alias_method :render_block , :render
94
94
95
- SYNTAX = /^\s *(#{ Liquid ::QuotedFragment } )\s +(?:for=(#{ Liquid ::QuotedFragment } ))(?:\s +(defaultTab))?/o
95
+ SYNTAX = /^\s *(#{ Liquid ::QuotedFragment } )\s +(?:for=(#{ Liquid ::QuotedFragment } ))? (?:\s +(defaultTab))?/o
96
96
Syntax = SYNTAX
97
97
98
98
def initialize ( block_name , markup , tokens )
99
99
super
100
100
101
101
if markup =~ SYNTAX
102
102
@tab = Tabs ::unquote ( $1)
103
- @name = Tabs ::unquote ( $2)
103
+ if $2
104
+ @name = Tabs ::unquote ( $2)
105
+ end
104
106
@anchor = Tabs ::asAnchor ( @tab )
105
107
if $3
106
108
@defaultTab = true
@@ -122,6 +124,10 @@ def render(context)
122
124
if tab_env . nil?
123
125
raise SyntaxError . new ( "Tab block '#{ tabcontent . label } ' must be inside a tabs block" )
124
126
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
125
131
environment [ "tabs-#{ tab_env } " ] ||= [ ]
126
132
environment [ "tabs-#{ tab_env } " ] << tabcontent
127
133
end
You can’t perform that action at this time.
0 commit comments