docs: use text attribute for default/example

This commit is contained in:
Bryton Hall 2023-06-13 18:32:09 -04:00
parent 2b8e452ef2
commit 0456c92538
2 changed files with 6 additions and 8 deletions

View file

@ -23,10 +23,10 @@
<tr> <tr>
<td>Default</td> <td>Default</td>
<td>{{ partial "highlight" $option.default }}</td> <td>{{ partial "highlight" $option.default.text }}</td>
</tr> </tr>
{{ with $option.example }} {{ with $option.example.text }}
<tr> <tr>
<td>Example</td> <td>Example</td>
<td>{{ partial "highlight" . }}</td> <td>{{ partial "highlight" . }}</td>

View file

@ -1,10 +1,8 @@
{{ $text := . }} {{ $text := . }}
{{/* if text is a multiline string add nix's double single-quotes */}} {{ if not $text }}
{{ if in $text "\n" }} {{/* add a blank character to prevent poor formatting */}}
{{ $text = print "''\n " (strings.TrimSuffix " " (replace $text "\n" "\n ") ) "''" }} {{ $text = " " }}
{{ else }}
{{ $text = $text | jsonify (dict "indent" " ") }}
{{ end }} {{ end }}
{{- transform.Highlight $text "nix" }} {{- transform.Highlight $text "nix" }}