Skip to content

Commit 3cfc0b1

Browse files
authored
feat(params): allow specifying multiple types (#61)
feat(hugo/shortcode-params): allow specifying multiple types
1 parent 4a8188b commit 3cfc0b1

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

layouts/shortcodes/hugo/shortcode-params.html

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
{{- $paramHeadingLevel := add 1 $headingStartLevel }}
1515
{{- range $params }}
1616
{{- $name := printf (cond (default false .deprecated) "~~`%s`~~" "`%s`") .name }}
17+
{{- $type := default "string" .type }}
18+
{{- if reflect.IsSlice $type }}
19+
{{- $type = delimit (apply $type "printf" "`%s`" ".") "/" }}
20+
{{- else }}
21+
{{- $type = printf "`%s`" $type }}
22+
{{- end }}
1723
{{- printf "%s %s\n" (strings.Repeat $paramHeadingLevel "#") $name }}
1824
{{- printf
1925
"| %s | %s | %s | %s | %s | %s |\n"
@@ -26,10 +32,10 @@
2632
}}
2733
{{- printf "| --- | :-: | :-: | :-: | :-: | :-: |\n" }}
2834
{{- printf
29-
"| %s | %s | `%s` | %s | %s | %s |\n"
35+
"| %s | %s | %s | %s | %s | %s |\n"
3036
(cond (isset . "position") (printf "`#%d`" .position) "-")
3137
$name
32-
(default "string" .type)
38+
$type
3339
(cond (default false .required) "✓" "-")
3440
(cond (isset . "default") (printf "`%s`" (string .default)) "-")
3541
(cond (isset . "since") (printf "`%s`" (string .since)) "-")

layouts/shortcodes/params.html

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
{{- range $params }}
1818
{{- $name := printf (cond (default false .deprecated) "~~`%s`~~" "`%s`") .name }}
1919
{{- $ctx := default $context .context }}
20+
{{- $type := default "string" .type }}
21+
{{- if reflect.IsSlice $type }}
22+
{{- $type = delimit (apply $type "printf" "`%s`" ".") "/" }}
23+
{{- else }}
24+
{{- $type = printf "`%s`" $type }}
25+
{{- end }}
2026
{{- printf "%s %s\n" (strings.Repeat $paramHeadingLevel "#") $name }}
2127
{{- printf
2228
"| %s | %s | %s | %s | %s | %s |\n"
@@ -29,10 +35,10 @@
2935
}}
3036
{{- printf "| --- | :-: | :-: | :-: | :-: | :-: |\n" }}
3137
{{- printf
32-
"| %s | %s | `%s` | %s | %s | %s |\n"
38+
"| %s | %s | %s | %s | %s | %s |\n"
3339
$name
3440
(cond (not $ctx) "-" $ctx | printf "`%s`")
35-
(default "string" .type)
41+
$type
3642
(cond (default false .required) "✓" "-")
3743
(cond (isset . "default") (printf "`%s`" (string .default)) "-")
3844
(cond (isset . "since") (printf "`%s`" (string .since)) "-")

0 commit comments

Comments
 (0)