Skip to content

Commit 866d1dd

Browse files
DOC-5991 all trees solid
1 parent 1aaa4ef commit 866d1dd

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

content/develop/data-types/compare-data-types.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ types. JSON generally has the highest requirements for memory and processing,
156156
followed by hashes, and then strings. Use the decision tree below as a guide to
157157
choosing the best data type for your task.
158158

159-
```decision-tree
159+
```decision-tree {id="documents-tree"}
160+
id: documents-tree
161+
scope: documents
160162
rootQuestion: root
161163
questions:
162164
root:
@@ -250,7 +252,9 @@ Note that if you need to store extra information for the keys in a set
250252
or sorted set, you can do so with an auxiliary hash or JSON object that has field
251253
names matching the keys in the collection.
252254

253-
```decision-tree
255+
```decision-tree {id="collections-tree"}
256+
id: collections-tree
257+
scope: collections
254258
rootQuestion: root
255259
questions:
256260
root:
@@ -310,7 +314,9 @@ You would normally store sequences of string or binary data using sorted sets,
310314
lists or streams. They each have advantages and disadvantages for particular purposes.
311315
Use the decision tree below as a guide to choosing the best data type for your task.
312316

313-
```decision-tree
317+
```decision-tree {id="sequences-tree"}
318+
id: sequences-tree
319+
scope: sequences
314320
rootQuestion: root
315321
questions:
316322
root:

layouts/_default/_markup/render-codeblock-decision-tree.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,27 @@
22
{{- /* Preserve YAML source for visual display and JavaScript parsing */ -}}
33
<pre class="decision-tree-source">{{ .Inner | htmlEscape | safeHTML }}</pre>
44

5+
{{- /* Extract id and scope from YAML for metadata (only top-level fields) */ -}}
6+
{{- $lines := split .Inner "\n" -}}
7+
{{- $id := "" -}}
8+
{{- $scope := "" -}}
9+
{{- range $lines -}}
10+
{{- /* Only process lines that don't start with whitespace (top-level fields) */ -}}
11+
{{- if and (gt (len .) 0) (ne (index . 0) 32) (ne (index . 0) 9) -}}
12+
{{- $trimmed := strings.TrimSpace . -}}
13+
{{- if strings.HasPrefix $trimmed "id:" -}}
14+
{{- $afterPrefix := strings.Replace $trimmed "id:" "" 1 -}}
15+
{{- $id = strings.TrimSpace $afterPrefix -}}
16+
{{- end -}}
17+
{{- if strings.HasPrefix $trimmed "scope:" -}}
18+
{{- $afterPrefix := strings.Replace $trimmed "scope:" "" 1 -}}
19+
{{- $scope = strings.TrimSpace $afterPrefix -}}
20+
{{- end -}}
21+
{{- end -}}
22+
{{- end -}}
23+
524
{{- /* Embed metadata as custom JSON for AI agents */ -}}
6-
{{- $metadata := dict "type" "decision-tree" -}}
25+
{{- $metadata := dict "type" "decision-tree" "id" $id "scope" $scope -}}
726

827
{{ $jsonMetadata := $metadata | jsonify (dict "indent" " ") }}
928
{{ printf "<script type=\"application/json\" data-redis-metadata=\"decision-tree\">\n%s\n</script>" $jsonMetadata | safeHTML }}

0 commit comments

Comments
 (0)