2525
2626 <div class="tabs">
2727 <ul class="tab-strip tab-strip--singleton" role="tablist">
28- {{ for tab in tabs sortLanguages }}
28+ {{ for tab in tabs FILTER }}
2929 {{ # Only render the tab here if i < 5 }}
3030 {{ if i lessThan(5) }}
3131 <li class="tab-strip__element" data-tabid="{{ tab.id }}" role="tab" aria-selected="{{ if i zero }}true{{ else }}false{{ end }}">{{ tab.name }}</li>
3232 {{ end }}
3333 {{ end }}
34- {{ if tabs numberOfLanguages greaterThan(5) }}
34+ {{ if tabs len greaterThan(5) }}
3535 <li class="tab-strip__element dropdown">
3636 <a class="dropdown-toggle" data-toggle="dropdown">Other <span class="caret"></span></a>
3737 <ul class="dropdown-menu tab-strip__dropdown" role="menu">
38- {{ for tab in tabs sortLanguages }}
38+ {{ for tab in tabs FILTER }}
3939 {{ # Only render the tab here if i >= 5 }}
4040 {{ if i greaterThanOrEqual(5) }}
4141 <li data-tabid="{{ tab.id }}" aria-selected="{{ if i zero }}true{{ else }}false{{ end }}">{{ tab.name }}</li>
4646 {{ end }}
4747 </ul>
4848 <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 }}
7650 <div class="tabpanel-{{ tab.id }}">
7751
7852{{ tab.content convertSections }}
11084'''
11185
11286def setup (app ):
87+ # Handle headers inside tab directives
11388 directive = template .create_directive ('h1' , H1_TEMPLATE , template .BUILT_IN_PATH , True )
11489 app .add_directive ('h1' , directive )
11590
@@ -122,11 +97,13 @@ def setup(app):
12297 directive = template .create_directive ('h4' , H4_TEMPLATE , template .BUILT_IN_PATH , True )
12398 app .add_directive ('h4' , directive )
12499
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 )
127103
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 )
130107
131108 return {'parallel_read_safe' : True ,
132109 'parallel_write_safe' : True }
@@ -141,11 +118,6 @@ def convertSections(tabContent):
141118
142119fett .Template .FILTERS ['convertSections' ] = convertSections
143120
144- def numberOfLanguages (tabData ):
145- return len (LANGUAGES_RAW )
146-
147- fett .Template .FILTERS ['numberOfLanguages' ] = numberOfLanguages
148-
149121def getLanguageNames (tabData ):
150122 for tab in tabData :
151123 index = LANGUAGES_IDS .index (tab ['id' ])
0 commit comments