Skip to content

Commit cacf622

Browse files
committed
layouts: render table with tr ids set to first td
This is in preparation of nicer table indexing with Algolia. Signed-off-by: Luca Zeuch <[email protected]>
1 parent e4a5e40 commit cacf622

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<table
2+
{{- range $k, $v := .Attributes }}
3+
{{- if $v }}
4+
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
5+
{{- end }}
6+
{{- end }}>
7+
<thead>
8+
{{- range .THead }}
9+
<tr>
10+
{{- range . }}
11+
<th
12+
{{- with .Alignment }}
13+
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
14+
{{- end -}}
15+
>
16+
{{- .Text -}}
17+
</th>
18+
{{- end }}
19+
</tr>
20+
{{- end }}
21+
</thead>
22+
<tbody>
23+
{{- range .TBody }}
24+
<tr id={{(index . 0).Text | safeHTMLAttr }}>
25+
{{- range . }}
26+
<td
27+
{{- with .Alignment }}
28+
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
29+
{{- end -}}
30+
>
31+
{{- .Text -}}
32+
</td>
33+
{{- end }}
34+
</tr>
35+
{{- end }}
36+
</tbody>
37+
</table>

0 commit comments

Comments
 (0)