Skip to content

Commit 790970f

Browse files
stefanvjarrodmillman
authored andcommitted
Add tomlToTable equivalent of yamlToTable
1 parent b8b3fd0 commit 790970f

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

layouts/shortcodes/tomlToTable.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{/*
2+
3+
doc: Render TOML to an HTML table.
4+
5+
{{< tomlToTable >}}
6+
7+
[[row]]
8+
type = 'header'
9+
10+
[[row.column]]
11+
body = 'Project'
12+
13+
[[row.column]]
14+
body = 'Available Packages'
15+
16+
[[row.column]]
17+
body = 'Download location'
18+
19+
[[row]]
20+
21+
[[row.column]]
22+
body = 'NumPy'
23+
24+
[[row.column]]
25+
body = '''Official *source code* (all platforms) and *binaries* for<br />
26+
**Windows**, **Linux**, and **Mac OS X**'''
27+
28+
[[row.column]]
29+
body = '[PyPi page for NumPy](https://pypi.python.org/pypi/numpy)'
30+
31+
[[row]]
32+
33+
[[row.column]]
34+
body = 'SciPy'
35+
36+
[[row.column]]
37+
body = '''Official *source code* (all platforms) and *binaries* for<br />
38+
**Windows**, **Linux**, and **Mac OS X**'''
39+
40+
[[row.column]]
41+
align = 'right'
42+
body = '''[SciPy release page](https://github.com/scipy/scipy/releases) (sources)<br />
43+
[PyPI page for SciPy](https://pypi.python.org/pypi/scipy) (all)'''
44+
45+
{{< /tomlToTable >}}
46+
47+
*/}}
48+
49+
{{ $arg := .Get 0 }}
50+
{{ $data := .Inner | transform.Unmarshal }}
51+
52+
{{ with $data }}
53+
<table>
54+
{{ range $row := .row }}
55+
<tr>
56+
{{ $el := "td" }}
57+
{{ if (eq $row.type "header") }}
58+
{{ $el = "th" }}
59+
{{ end }}
60+
{{ range $col := .column }}
61+
{{ printf "<%s" $el | safeHTML }} colspan="{{ $col.colspan }}" rowspan="{{ $col.rowspan }}" {{ printf ">" | safeHTML }}
62+
{{ $col.body | markdownify }}
63+
{{ printf "</%s>" $el | safeHTML }}
64+
{{ end }}
65+
</tr>
66+
{{ end }}
67+
</table>
68+
{{ end }}

0 commit comments

Comments
 (0)