From 27b07a80f1872205dfeb949e9b90cf85f6e43744 Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Fri, 17 May 2024 09:19:12 +0200
Subject: refactor: move general results template code into results template
---
frontend/templates/blocks/options.gotmpl | 113 +++++++++++++------------------
frontend/templates/blocks/results.gotmpl | 23 +++++++
2 files changed, 71 insertions(+), 65 deletions(-)
create mode 100644 frontend/templates/blocks/results.gotmpl
(limited to 'frontend/templates/blocks')
diff --git a/frontend/templates/blocks/options.gotmpl b/frontend/templates/blocks/options.gotmpl
index ad92c17..806ca2f 100644
--- a/frontend/templates/blocks/options.gotmpl
+++ b/frontend/templates/blocks/options.gotmpl
@@ -1,71 +1,54 @@
-{{- define "results" }}
- {{- if gt .Results.Total 0 }}
-
- {{- range .Results.Hits }}
- {{- with .Data }}
-
-
- {{ .Name }}
-
- {{ markdown .Description }}
-
- {{- with .Type }}
- - Type
- {{ . }}
- {{- end }}
- {{- with .Default }}
- {{- if or .Text .Markdown }}
- - Default
- -
- {{- if .Markdown }}
- {{ markdown .Markdown }}
- {{- else }}
-
{{ .Text }}
- {{- end }}
-
- {{- end }}
- {{- end }}
- {{- with .Example }}
- {{- if or .Text .Markdown }}
- - Example
- -
- {{- if .Markdown }}
- {{ markdown .Markdown }}
- {{- else }}
-
{{ .Text }}
- {{- end }}
-
+{{- define "hits" }}
+ {{- range . }}
+ {{- with .Data }}
+
+
+ {{ .Name }}
+
+ {{ markdown .Description }}
+
+ {{- with .Type }}
+ - Type
+ {{ . }}
+ {{- end }}
+ {{- with .Default }}
+ {{- if or .Text .Markdown }}
+ - Default
+ -
+ {{- if .Markdown }}
+ {{ markdown .Markdown }}
+ {{- else }}
+
{{ .Text }}
{{- end }}
- {{- end }}
- {{- with .RelatedPackages }}
- - Related Packages
- - {{ . }}
- {{- end }}
- {{- with .Declarations }}
- - Declared
- {{- range . }}
- -
- {{ .Name }}
-
+
+ {{- end }}
+ {{- end }}
+ {{- with .Example }}
+ {{- if or .Text .Markdown }}
+ - Example
+ -
+ {{- if .Markdown }}
+ {{ markdown .Markdown }}
+ {{- else }}
+
{{ .Text }}
{{- end }}
- {{- end }}
-
-
- {{- end }}
- {{- end }}
-
-
- {{- else }}
- Nothing found
+
+
+ {{- end }}
{{- end }}
{{- end }}
diff --git a/frontend/templates/blocks/results.gotmpl b/frontend/templates/blocks/results.gotmpl
new file mode 100644
index 0000000..95c89ca
--- /dev/null
+++ b/frontend/templates/blocks/results.gotmpl
@@ -0,0 +1,23 @@
+{{- define "results" }}
+ {{- with .Results }}
+ {{- if gt .Total 0 }}
+
+ {{ block "hits" .Hits }}
+ {{ end }}
+
+
+ {{- else }}
+ Nothing found
+ {{- end }}
+ {{- end }}
+{{- end }}
--
cgit 1.4.1