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>
<td>Default</td>
<td>{{ partial "highlight" $option.default }}</td>
<td>{{ partial "highlight" $option.default.text }}</td>
</tr>
{{ with $option.example }}
{{ with $option.example.text }}
<tr>
<td>Example</td>
<td>{{ partial "highlight" . }}</td>

View file

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