File tree Expand file tree Collapse file tree 4 files changed +55
-48
lines changed
Expand file tree Collapse file tree 4 files changed +55
-48
lines changed Original file line number Diff line number Diff line change @@ -171,26 +171,32 @@ Code example from the PyData Sphinx Theme's kitchen sink:
171171
172172{{< tabs >}}
173173
174- {{< tab "c++" >}}
174+ [[ tab]]
175+ name = 'c++'
176+ content = '''
175177
176178``` c++
177179int main (const int argc, const char ** argv) {
178180 return 0;
179181}
180182```
181183
182- {{< /tab >}}
184+ '''
183185
184- {{< tab "python" >}}
186+ [[tab]]
187+ name = 'python'
188+ content = '''
185189
186190```python
187191def main():
188192 return
189193```
190194
191- {{< /tab >}}
195+ '''
192196
193- {{< tab "java" >}}
197+ [[ tab]]
198+ name = 'java'
199+ content = '''
194200
195201``` java
196202class Main {
@@ -199,33 +205,39 @@ class Main {
199205}
200206```
201207
202- {{< /tab >}}
208+ '''
203209
204- {{< tab "julia" >}}
210+ [[ tab]]
211+ name = 'julia'
212+ content = '''
205213
206214``` julia
207215function main ()
208216end
209217```
210218
211- {{< /tab >}}
219+ '''
212220
213- {{< tab "fortran" >}}
221+ [[ tab]]
222+ name ='fortran'
223+ content = '''
214224
215225``` fortran
216226PROGRAM main
217227END PROGRAM main
218228```
219229
220- {{< /tab >}}
230+ '''
221231
222232{{< /tabs >}}
223233
224234An example with headings
225235
226236{{< tabs >}}
227237
228- {{< tab "First example" >}}
238+ [[ tab]]
239+ name = 'First example'
240+ content = '''
229241
230242### How would this work?
231243
@@ -244,12 +256,13 @@ def foo(x):
244256#### What now?
245257
246258Well, this is a good question.
259+ '''
247260
248- {{< / tab >}}
249-
250- {{< tab "Second example" >}}
261+ [[ tab]]
262+ name = 'Second example'
263+ content = '''
251264Another hello world
252- {{< /tab >}}
265+ '''
253266
254267{{< /tabs >}}
255268
Original file line number Diff line number Diff line change 1+ {{- $groupId := .groupId }}
2+ {{- $tabs := .tabs }}
3+ < div class ="tabs ">
4+ < div role ="tablist " class ="automatic ">
5+ {{- range $idx, $tab := $tabs }}
6+ < button id ="{{ $groupId }}-tab-{{ $idx }} " type ="button " role ="tab " aria-selected ="{{ cond (eq $idx 0) "true " "false" }}" aria-controls="{{ $groupId }}-tabpanel-{{ $idx }} ">
7+ {{ .name }}
8+ </ button >
9+ {{- end }}
10+ </ div >
11+ {{- range $idx, $tab := $tabs }}
12+ < div id ="{{ $groupId }}-tabpanel-{{ $idx }} " role ="tabpanel " tabindex ="0 " aria-labelledby ="${{ $groupId }}-tab-{{ $idx }} ">
13+ {{- .content | markdownify -}}
14+ </ div >
15+ {{- end }}
16+ </ div >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 44
55{{< tabs > }}
66
7- {{< tab "c++" > }}
7+ [[tab]]
8+ name = 'c++'
9+ content = '''
810An example program in C++:
911```c++
1012int main(const int argc, const char **argv) {
1113 return 0;
1214}
1315```
1416It simply returns 0, indicating no errors.
15- {{ < /tab > }}
17+ '''
1618
17- {{< tab "python" > }}
19+ [[tab]]
20+ name = 'python'
21+ content = '''
1822An example program in Python:
1923```python
2024def main():
2125 return True
2226```
2327It returns `True`, indicating no errors.
24- {{ < /tab > }}
28+ '''
2529
2630{{< /tabs > }}
2731
2832*/}}
2933
30- <!-- Render inner tabs, which adds them to a scratch variable for this parent shortcode -->
31- {{- .Inner -}}
32- {{- $groupId := .Page.Scratch.Get "tabgroup" | default 0 -}}
33- {{- .Page.Scratch.Set "tabgroup" (add $groupId 1) -}}
34- < div class ="tabs ">
35- < div role ="tablist " class ="automatic ">
36- {{- range $idx, $tab := .Scratch.Get "tabs" }}
37- < button id ="{{ $groupId }}-tab-{{ $idx }} " type ="button " role ="tab " aria-selected ="{{ cond (eq $idx 0) "true " "false" }}" aria-controls="{{ $groupId }}-tabpanel-{{ $idx }} ">
38- {{ .name }}
39- </ button >
40- {{- end }}
41- </ div >
42- {{- range $idx, $tab := .Scratch.Get "tabs" }}
43- < div id ="{{ $groupId }}-tabpanel-{{ $idx }} " role ="tabpanel " tabindex ="0 " aria-labelledby ="${{ $groupId }}-tab-{{ $idx }} ">
44- {{- .content | markdownify -}}
45- </ div >
46- {{- end }}
47- </ div >
34+ {{- $groupId := printf "%03d" $.Ordinal -}}
35+ {{- $tabs := (index (.Inner | transform.Unmarshal) "tab") -}}
36+ {{ partial "_elements/tabs" (dict "groupId" $groupId "tabs" $tabs) }}
You can’t perform that action at this time.
0 commit comments