Skip to content

Commit

Permalink
docs: use text attribute for default/example
Browse files Browse the repository at this point in the history
  • Loading branch information
hall committed Jun 13, 2023
1 parent 2b8e452 commit 0456c92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/layouts/partials/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 4 additions & 6 deletions docs/layouts/partials/highlight.html
Original file line number Diff line number Diff line change
@@ -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" }}

0 comments on commit 0456c92

Please sign in to comment.