|
5 | 5 | {{< tomlToTable >}}
|
6 | 6 |
|
7 | 7 | caption = 'Table caption'
|
8 |
| -align = [ "left", "left", "right" ] |
9 |
| -header-rows = 1 |
| 8 | +align = ["left", "left", "right"] |
| 9 | +widths = ["10%", "50%", "20%"] |
| 10 | +headerrows = 1 |
10 | 11 | footer-rows = 3
|
11 | 12 | stub-columns = 1
|
12 | 13 |
|
13 | 14 | [[row]]
|
14 |
| -type = 'header' |
15 | 15 |
|
16 | 16 | [[row.column]]
|
17 | 17 | body = 'Project'
|
|
44 | 44 | **Windows**, **Linux**, and **Mac OS X**'''
|
45 | 45 |
|
46 | 46 | [[row.column]]
|
47 |
| -align = 'right' |
48 | 47 | body = '''[SciPy release page](https://github.com/scipy/scipy/releases) (sources)<br />
|
49 | 48 | [PyPI page for SciPy](https://pypi.python.org/pypi/scipy) (all)'''
|
50 | 49 |
|
51 | 50 | {{< /tomlToTable >}}
|
52 | 51 |
|
53 | 52 | */}}
|
54 | 53 |
|
55 |
| -{{ $arg := .Get 0 }} |
56 |
| -{{ $data := .Inner | transform.Unmarshal }} |
57 |
| - |
58 |
| -{{ with $data }} |
59 |
| -<table class="table"> |
60 |
| - {{ range $i, $row := .row }} |
61 |
| - {{if (modBool $i 2)}} |
62 |
| - <tr class="row-odd"> |
63 |
| - {{else}} |
64 |
| - <tr class="row-even"> |
65 |
| - {{end}} |
66 |
| - {{ $el := "td" }} |
67 |
| - {{ if (eq $row.type "header") }} |
68 |
| - {{ $el = "th class='head'" }} |
69 |
| - {{ end }} |
70 |
| - {{ range $col := .column }} |
71 |
| - {{ printf "<%s" $el | safeHTML }} colspan="{{ $col.colspan }}" rowspan="{{ $col.rowspan }}" {{ printf ">" | safeHTML }} |
72 |
| - {{ $col.body | markdownify }} |
73 |
| - {{ printf "</%s>" $el | safeHTML }} |
74 |
| - {{ end }} |
75 |
| - </tr> |
| 54 | +{{- $data := .Inner | transform.Unmarshal }} |
| 55 | +{{- $id := printf "id%03d" $.Ordinal -}} |
| 56 | +{{- $align := $data.align }} |
| 57 | +{{- $numrows := $data.row | len }} |
| 58 | +{{- $headerrows := or $data.headerrows 0 }} |
| 59 | +{{- $header := first $headerrows $data.row }} |
| 60 | +{{- $body := last (math.Sub $numrows $headerrows) $data.row }} |
| 61 | + |
| 62 | +<table class="table" id="{{ $id }}"> |
| 63 | + {{- with $data.caption }} |
| 64 | + <caption><span class="caption-text">{{ . }}</span><a class="headerlink" href="#{{ $id }}" title="Link to this table">#</a></caption> |
| 65 | + {{- end }} |
| 66 | + {{- with $data.widths }} |
| 67 | + <colgroup> |
| 68 | + {{- range . }} |
| 69 | + <col style="width: {{ . }}" /> |
| 70 | + {{- end }} |
| 71 | + </colgroup> |
76 | 72 | {{ end }}
|
| 73 | + {{- if $header }}<thead> |
| 74 | + {{- range $row_idx, $row := $header }} |
| 75 | + {{ if (modBool $row_idx 2) }}<tr class="row-odd">{{- else }}<tr class="row-even">{{- end }} |
| 76 | + {{- range $col_idx, $col := .column }} |
| 77 | + {{- $alignment := or (index $align $col_idx) "left" }} |
| 78 | + <th class="head" style="text-align:{{ $alignment }}"> |
| 79 | + {{ $col.body | markdownify }} |
| 80 | + </th> |
| 81 | + {{- end }} |
| 82 | + </tr> |
| 83 | + {{- end }} |
| 84 | + </thead> |
| 85 | + {{- end }} |
| 86 | + <tbody> |
| 87 | + {{- range $row_idx, $row := $body }} |
| 88 | + {{ if (modBool (add $row_idx $headerrows) 2) }}<tr class="row-odd">{{- else }}<tr class="row-even">{{- end }} |
| 89 | + {{- range $col_idx, $col := .column }} |
| 90 | + {{- $alignment := or (index $align $col_idx) "left" }} |
| 91 | + <td class="head" style="text-align:{{ $alignment }}"> |
| 92 | + {{ $col.body | markdownify }} |
| 93 | + </td> |
| 94 | + {{- end }} |
| 95 | + </tr> |
| 96 | + {{- end }} |
| 97 | + </tbody> |
77 | 98 | </table>
|
78 |
| -{{ end }} |
|
0 commit comments