summaryrefslogtreecommitdiff
path: root/layouts/_default/_markup/render-table.html
blob: 5534d3a6553539fdcd057dfe7f16161ab1fb767d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{{/*
Default table rendered plus an outer div to align and overflow tables
accordingly.
Ref: https://gohugo.io/render-hooks/tables/
*/}}
<div class="table-outer">
    <table
        {{- range $k, $v :=.Attributes }}
        {{- if $v }}
        {{- printf " %s=%q" $k $v | safeHTMLAttr }}
        {{- end }}
        {{- end }}>
        <thead>
            {{- range .THead }}
            <tr>
                {{- range . }}
                <th
                    {{- with .Alignment }}
                    {{- printf " style=%q" (printf "text-align: %s" .) |
                    safeHTMLAttr }}
                    {{- end -}}>
                    {{- .Text -}}
                </th>
                {{- end }}
            </tr>
            {{- end }}
        </thead>
        <tbody>
            {{- range .TBody }}
            <tr>
                {{- range . }}
                <td
                    {{- with .Alignment }}
                    {{- printf " style=%q" (printf "text-align: %s" .) |
                    safeHTMLAttr }}
                    {{- end -}}>
                    {{- .Text -}}
                </td>
                {{- end }}
            </tr>
            {{- end }}
        </tbody>
    </table>
</div>