Skip to content

Commit 2325423

Browse files
DOC-5517 named clients-example parameters
1 parent 8771231 commit 2325423

File tree

2 files changed

+58
-8
lines changed

2 files changed

+58
-8
lines changed

layouts/partials/tabbed-clients-example.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@
1414
{{ $tabs := slice }}
1515
{{/* Render redis-cli example from inner content if any */}}
1616
{{ if (ne (trim $redisCommands "\n") "") }}
17-
{{ $redisCliContent := highlight (trim $redisCommands "\n") "plaintext" (printf "linenos=false,hl_lines=1-%d" $redisCommandsLineLimit ) }}
17+
{{ $highlightOptions := "linenos=false" }}
18+
{{ $redisCommandsLineLimitInt := 0 }}
19+
{{ if $redisCommandsLineLimit }}
20+
{{ $redisCommandsLineLimitInt = int $redisCommandsLineLimit }}
21+
{{ end }}
22+
{{ if gt $redisCommandsLineLimitInt 0 }}
23+
{{ $highlightOptions = printf "linenos=false,hl_lines=1-%d" $redisCommandsLineLimitInt }}
24+
{{ end }}
25+
{{ $redisCliContent := highlight (trim $redisCommands "\n") "plaintext" $highlightOptions }}
1826
{{ $tabs = $tabs | append (dict "title" "redis-cli" "displayName" $cliTabName "content" $redisCliContent "limit" $redisCommandsLineLimit "customFooterLinkText" $cliFooterLinkText "customFooterLinkUrl" $cliFooterLinkUrl) }}
1927
{{ end }}
2028

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,51 @@
1-
{{ .Scratch.Set "example" (.Get 0) }}
2-
{{ .Scratch.Set "step" (.Get 1) }}
3-
{{ .Scratch.Set "lang" (.Get 2) }}
4-
{{ .Scratch.Set "maxLines" (.Get 3) }}
5-
{{ .Scratch.Set "cli_tab_name" (.Get 4) }}
6-
{{ .Scratch.Set "cli_footer_link_text" (.Get 5) }}
7-
{{ .Scratch.Set "cli_footer_link_url" (.Get 6) }}
1+
{{/*
2+
clients-example shortcode - supports both positional and named parameters
3+
4+
Named parameters:
5+
- set: Name of the example set (required)
6+
- step: Example step name (required)
7+
- lang_filter: Language filter (optional, default: "")
8+
- max_lines: Maximum number of lines shown by default (optional, default: 100)
9+
- dft_tab_name: Custom first tab name (optional, default: ">_ Redis CLI")
10+
- dft_tab_link_title: Custom first tab footer link title (optional)
11+
- dft_tab_url: Custom first tab footer link URL (optional)
12+
13+
Positional parameters (for backward compatibility):
14+
- 0: example set name
15+
- 1: step name
16+
- 2: language filter
17+
- 3: max lines
18+
- 4: custom first tab name
19+
- 5: custom first tab footer link title
20+
- 6: custom first tab footer link URL
21+
*/}}
22+
23+
{{/* Determine if we're using named or positional parameters */}}
24+
{{ $usingNamedParams := false }}
25+
{{ if .Get "set" }}
26+
{{ $usingNamedParams = true }}
27+
{{ end }}
28+
29+
{{/* Set parameters based on whether we're using named or positional */}}
30+
{{ if $usingNamedParams }}
31+
{{/* Named parameters */}}
32+
{{ .Scratch.Set "example" (.Get "set") }}
33+
{{ .Scratch.Set "step" (.Get "step") }}
34+
{{ .Scratch.Set "lang" (or (.Get "lang_filter") (.Get "language") "") }}
35+
{{ .Scratch.Set "maxLines" (.Get "max_lines") }}
36+
{{ .Scratch.Set "cli_tab_name" (.Get "dft_tab_name") }}
37+
{{ .Scratch.Set "cli_footer_link_text" (.Get "dft_tab_link_title") }}
38+
{{ .Scratch.Set "cli_footer_link_url" (.Get "dft_tab_url") }}
39+
{{ else }}
40+
{{/* Positional parameters (backward compatibility) */}}
41+
{{ .Scratch.Set "example" (.Get 0) }}
42+
{{ .Scratch.Set "step" (.Get 1) }}
43+
{{ .Scratch.Set "lang" (.Get 2) }}
44+
{{ .Scratch.Set "maxLines" (.Get 3) }}
45+
{{ .Scratch.Set "cli_tab_name" (.Get 4) }}
46+
{{ .Scratch.Set "cli_footer_link_text" (.Get 5) }}
47+
{{ .Scratch.Set "cli_footer_link_url" (.Get 6) }}
48+
{{ end }}
49+
850
{{ .Scratch.Set "redisCommands" .Inner }}
951
{{ partial "tabbed-clients-example.html" . }}

0 commit comments

Comments
 (0)