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:
171
171
172
172
{{< tabs >}}
173
173
174
- {{< tab "c++" >}}
174
+ [[ tab]]
175
+ name = 'c++'
176
+ content = '''
175
177
176
178
``` c++
177
179
int main (const int argc, const char ** argv) {
178
180
return 0;
179
181
}
180
182
```
181
183
182
- {{< /tab >}}
184
+ '''
183
185
184
- {{< tab "python" >}}
186
+ [[tab]]
187
+ name = 'python'
188
+ content = '''
185
189
186
190
```python
187
191
def main():
188
192
return
189
193
```
190
194
191
- {{< /tab >}}
195
+ '''
192
196
193
- {{< tab "java" >}}
197
+ [[ tab]]
198
+ name = 'java'
199
+ content = '''
194
200
195
201
``` java
196
202
class Main {
@@ -199,33 +205,39 @@ class Main {
199
205
}
200
206
```
201
207
202
- {{< /tab >}}
208
+ '''
203
209
204
- {{< tab "julia" >}}
210
+ [[ tab]]
211
+ name = 'julia'
212
+ content = '''
205
213
206
214
``` julia
207
215
function main ()
208
216
end
209
217
```
210
218
211
- {{< /tab >}}
219
+ '''
212
220
213
- {{< tab "fortran" >}}
221
+ [[ tab]]
222
+ name ='fortran'
223
+ content = '''
214
224
215
225
``` fortran
216
226
PROGRAM main
217
227
END PROGRAM main
218
228
```
219
229
220
- {{< /tab >}}
230
+ '''
221
231
222
232
{{< /tabs >}}
223
233
224
234
An example with headings
225
235
226
236
{{< tabs >}}
227
237
228
- {{< tab "First example" >}}
238
+ [[ tab]]
239
+ name = 'First example'
240
+ content = '''
229
241
230
242
### How would this work?
231
243
@@ -244,12 +256,13 @@ def foo(x):
244
256
#### What now?
245
257
246
258
Well, this is a good question.
259
+ '''
247
260
248
- {{< / tab >}}
249
-
250
- {{< tab "Second example" >}}
261
+ [[ tab]]
262
+ name = 'Second example'
263
+ content = '''
251
264
Another hello world
252
- {{< /tab >}}
265
+ '''
253
266
254
267
{{< /tabs >}}
255
268
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 4
4
5
5
{{< tabs > }}
6
6
7
- {{< tab "c++" > }}
7
+ [[tab]]
8
+ name = 'c++'
9
+ content = '''
8
10
An example program in C++:
9
11
```c++
10
12
int main(const int argc, const char **argv) {
11
13
return 0;
12
14
}
13
15
```
14
16
It simply returns 0, indicating no errors.
15
- {{ < /tab > }}
17
+ '''
16
18
17
- {{< tab "python" > }}
19
+ [[tab]]
20
+ name = 'python'
21
+ content = '''
18
22
An example program in Python:
19
23
```python
20
24
def main():
21
25
return True
22
26
```
23
27
It returns `True`, indicating no errors.
24
- {{ < /tab > }}
28
+ '''
25
29
26
30
{{< /tabs > }}
27
31
28
32
*/}}
29
33
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