propertylist.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {{- $name := .Get "name" -}}
  2. {{- $sort := .Get "sort" -}}
  3. {{- $order := default "asc" (.Get "order") -}}
  4. {{- $showAnchor := (and (default true .Page.Params.geekdocAnchor) (default true .Page.Site.Params.geekdocAnchor)) -}}
  5. {{- if .Site.Data.properties }}
  6. <dl class="gdoc-props">
  7. {{- with (index .Site.Data.properties (split $name ".")) }}
  8. {{- $properties := .properties }}
  9. {{- with $sort }}
  10. {{- $properties = (sort $properties . $order) }}
  11. {{- end }}
  12. {{- range $properties }}
  13. {{- $uniqueAnchor := anchorize (printf "%s-%s" $name .name) | safeHTML }}
  14. <dt class="flex flex-wrap align-center gdoc-props__meta"{{ if $showAnchor }} id="{{ $uniqueAnchor }}"{{ end }}>
  15. <span class="gdoc-props__title">{{ .name }}</span>
  16. {{- if .required }}
  17. <span class="gdoc-props__tag warning">{{ i18n "propertylist_required" | lower }}</span>
  18. {{- else }}
  19. <span class="gdoc-props__tag tip">{{ i18n "propertylist_optional" | lower }}</span>
  20. {{- end }}
  21. {{- with .type }}
  22. <span class="gdoc-props__tag note">{{ . }}</span>
  23. {{- end }}
  24. {{- with .tags }}
  25. {{- $tags := . }}
  26. {{- if reflect.IsMap $tags }}
  27. {{- $tags = (index $tags $.Site.Language.Lang) }}
  28. {{- end }}
  29. {{- range $tags }}
  30. <span class="gdoc-props__tag">{{ . }}</span>
  31. {{- end }}
  32. {{- end }}
  33. {{- if $showAnchor }}
  34. <a data-clipboard-text="{{ .Page.Permalink }}#{{ $uniqueAnchor }}" class="gdoc-page__anchor clip flex align-center" title="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" aria-label="{{ i18n "title_anchor_prefix" }} {{ .name | safeHTML }}" href="#{{ $uniqueAnchor }}">
  35. <svg class="gdoc-icon gdoc_link"><use xlink:href="#gdoc_link"></use></svg>
  36. </a>
  37. {{- end }}
  38. </dt>
  39. <dd>
  40. <div class="gdoc-props__description">
  41. {{- with .description }}
  42. {{- $desc := . }}
  43. {{- if reflect.IsMap $desc }}
  44. {{- $desc = (index $desc $.Site.Language.Lang) }}
  45. {{- end }}
  46. {{ $desc | $.Page.RenderString }}
  47. {{- end }}
  48. </div>
  49. <div class="gdoc-props__default">
  50. {{- with default "none" (.defaultValue | string) }}
  51. <span>{{ i18n "propertylist_default" | title }}:</span>
  52. <span>{{ . }}</span>
  53. {{- end }}
  54. </div>
  55. </dd>
  56. {{- end }}
  57. {{- end }}
  58. </dl>
  59. {{- end }}