25
25
26
26
<div class="tabs">
27
27
<ul class="tab-strip tab-strip--singleton" role="tablist">
28
- {{ for tab in tabs sortLanguages }}
28
+ {{ for tab in tabs FILTER }}
29
29
{{ # Only render the tab here if i < 5 }}
30
30
{{ if i lessThan(5) }}
31
31
<li class="tab-strip__element" data-tabid="{{ tab.id }}" role="tab" aria-selected="{{ if i zero }}true{{ else }}false{{ end }}">{{ tab.name }}</li>
32
32
{{ end }}
33
33
{{ end }}
34
- {{ if tabs numberOfLanguages greaterThan(5) }}
34
+ {{ if tabs len greaterThan(5) }}
35
35
<li class="tab-strip__element dropdown">
36
36
<a class="dropdown-toggle" data-toggle="dropdown">Other <span class="caret"></span></a>
37
37
<ul class="dropdown-menu tab-strip__dropdown" role="menu">
38
- {{ for tab in tabs sortLanguages }}
38
+ {{ for tab in tabs FILTER }}
39
39
{{ # Only render the tab here if i >= 5 }}
40
40
{{ if i greaterThanOrEqual(5) }}
41
41
<li data-tabid="{{ tab.id }}" aria-selected="{{ if i zero }}true{{ else }}false{{ end }}">{{ tab.name }}</li>
46
46
{{ end }}
47
47
</ul>
48
48
<div class="tabs__content" role="tabpanel">
49
- {{ for tab in tabs sortLanguages}}
50
- <div class="tabpanel-{{ tab.id }}">
51
-
52
- {{ tab.content convertSections }}
53
-
54
- .. raw:: html
55
-
56
- </div>
57
- {{ end }}
58
- </div>
59
- </div>
60
- '''
61
-
62
- TABSGS_TEMPLATE = '''
63
- .. raw:: html
64
-
65
- <div class="tabs">
66
- <ul class="tab-strip tab-strip--singleton" role="tablist">
67
- {{ for tab in tabs }}
68
- {{ # Only render the tab here if i < 5 }}
69
- {{ if i lessThan(5) }}
70
- <li class="tab-strip__element" data-tabid="{{ tab.id }}" role="tab" aria-selected="{{ if i zero }}true{{ else }}false{{ end }}">{{ tab.name }}</li>
71
- {{ end }}
72
- {{ end }}
73
- </ul>
74
- <div class="tabs__content" role="tabpanel">
75
- {{ for tab in tabs }}
49
+ {{ for tab in tabs FILTER }}
76
50
<div class="tabpanel-{{ tab.id }}">
77
51
78
52
{{ tab.content convertSections }}
110
84
'''
111
85
112
86
def setup (app ):
87
+ # Handle headers inside tab directives
113
88
directive = template .create_directive ('h1' , H1_TEMPLATE , template .BUILT_IN_PATH , True )
114
89
app .add_directive ('h1' , directive )
115
90
@@ -122,11 +97,13 @@ def setup(app):
122
97
directive = template .create_directive ('h4' , H4_TEMPLATE , template .BUILT_IN_PATH , True )
123
98
app .add_directive ('h4' , directive )
124
99
125
- directive = template .create_directive ('tabs' , TABS_TEMPLATE , template .BUILT_IN_PATH , True )
126
- app .add_directive ('tabs' , directive )
100
+ # Create drivers tab directive
101
+ directive = template .create_directive ('tabs-drivers' , TABS_TEMPLATE .replace ("FILTER" , "sortLanguages" ), template .BUILT_IN_PATH , True )
102
+ app .add_directive ('tabs-drivers' , directive )
127
103
128
- directive = template .create_directive ('tabs-gs' , TABSGS_TEMPLATE , template .BUILT_IN_PATH , True )
129
- app .add_directive ('tabs-gs' , directive )
104
+ # Create general purpose tab directive with no error checking
105
+ directive = template .create_directive ('tabs' , TABS_TEMPLATE .replace ("FILTER" , "" ), template .BUILT_IN_PATH , True )
106
+ app .add_directive ('tabs' , directive )
130
107
131
108
return {'parallel_read_safe' : True ,
132
109
'parallel_write_safe' : True }
@@ -141,11 +118,6 @@ def convertSections(tabContent):
141
118
142
119
fett .Template .FILTERS ['convertSections' ] = convertSections
143
120
144
- def numberOfLanguages (tabData ):
145
- return len (LANGUAGES_RAW )
146
-
147
- fett .Template .FILTERS ['numberOfLanguages' ] = numberOfLanguages
148
-
149
121
def getLanguageNames (tabData ):
150
122
for tab in tabData :
151
123
index = LANGUAGES_IDS .index (tab ['id' ])
0 commit comments