{{ $id := .Scratch.Get "example" }} {{ $step := .Scratch.Get "step" }} {{ $description := .Scratch.Get "description" }} {{ $difficulty := .Scratch.Get "difficulty" }} {{ $lang := .Scratch.Get "lang" }} {{ $redisCommands := .Scratch.Get "redisCommands" }} {{ $redisCommandsLineLimit := (or (.Scratch.Get "maxLines") 100) }} {{ $cliTabName := (or (.Scratch.Get "cli_tab_name") ">_ Redis CLI") }} {{ $cliFooterLinkText := .Scratch.Get "cli_footer_link_text" }} {{ $cliFooterLinkUrl := .Scratch.Get "cli_footer_link_url" }} {{ $showFooter := .Scratch.Get "show_footer" | default true }} {{/* Parse buildsUpon parameter into an array */}} {{ $buildsUponStr := .Scratch.Get "buildsUpon" }} {{ $buildsUpon := slice }} {{ if $buildsUponStr }} {{/* Split by comma and trim whitespace from each element */}} {{ $parts := split $buildsUponStr "," }} {{ range $part := $parts }} {{ $trimmed := trim $part " " }} {{ if $trimmed }} {{ $buildsUpon = $buildsUpon | append $trimmed }} {{ end }} {{ end }} {{ end }} {{/* Extract commands for this step from examples.json */}} {{ $commands := slice }} {{ if isset $.Site.Data.examples $id }} {{ $exampleData := index $.Site.Data.examples $id }} {{ if isset $exampleData "steps_commands" }} {{ if isset $exampleData.steps_commands $step }} {{ $commands = index $exampleData.steps_commands $step }} {{ end }} {{ end }} {{ end }} {{ if not (isset $.Site.Data.examples $id) }} {{ warnf "[tabbed-clients-example] Example not found %q for %q" $id $.Page }} {{ end }} {{ $tabs := slice }} {{/* Render redis-cli example from inner content if any */}} {{ if (ne (trim $redisCommands "\n") "") }} {{ $highlightOptions := "linenos=false" }} {{ $redisCommandsLineLimitInt := 0 }} {{ if $redisCommandsLineLimit }} {{ $redisCommandsLineLimitInt = int $redisCommandsLineLimit }} {{ end }} {{ if gt $redisCommandsLineLimitInt 0 }} {{ $highlightOptions = printf "linenos=false,hl_lines=1-%d" $redisCommandsLineLimitInt }} {{ end }} {{ $redisCliContent := highlight (trim $redisCommands "\n") "plaintext" $highlightOptions }} {{ $cliTab := dict "title" "redis-cli" "displayName" $cliTabName "content" $redisCliContent "limit" $redisCommandsLineLimit "customFooterLinkText" $cliFooterLinkText "customFooterLinkUrl" $cliFooterLinkUrl }} {{ if gt (len $commands) 0 }} {{ $cliTab = merge $cliTab (dict "commands" $commands) }} {{ end }} {{ $tabs = $tabs | append $cliTab }} {{ end }} {{ $clientExamples := index $.Site.Data.examples $id }} {{ range $client := $.Site.Params.clientsexamples }} {{ $example := index $clientExamples $client }} {{ $clientConfig := index $.Site.Params.clientsconfig $client }} {{ $language := index $example "language" }} {{ $quickstartSlug := index $clientConfig "quickstartSlug" }} {{/* Check if language filter matches: either no filter or exact match in comma-separated list */}} {{ $langMatches := false }} {{ if eq $lang "" }} {{ $langMatches = true }} {{ else }} {{ range $filterLang := split $lang "," }} {{ if eq (strings.TrimSpace $filterLang) $client }} {{ $langMatches = true }} {{ end }} {{ end }} {{ end }} {{ if and ($example) $langMatches }} {{ $examplePath := index $example "target" }} {{ $options := printf "linenos=false" }} {{ if and (ne $step "") (isset $example "named_steps") (isset $example.named_steps $step) }} {{ $options = printf "%s,hl_lines=%s" $options (index $example.named_steps $step) }} {{ else }} {{ if and (isset $example "highlight") (index $example "highlight") }} {{ $options = printf "%s,hl_lines=%s" $options (delimit (index $example "highlight") " ") }} {{ end }} {{ end }} {{ if hasPrefix $language "java" }}{{ $language = "java"}}{{ end }} {{ $params := dict "language" $language "contentPath" $examplePath "options" $options }} {{ $content := partial "tabs/source.html" $params }} {{/* Extract binderId if it exists */}} {{ $binderId := index $example "binderId" }} {{/* Map display names for clients */}} {{ $displayName := $client }} {{ if eq $client "Node.js" }} {{ $displayName = "JavaScript (node-redis)" }} {{ else if eq $client "ioredis" }} {{ $displayName = "JavaScript (ioredis)" }} {{ end }} {{ $clientTab := dict "title" $client "displayName" $displayName "language" $client "quickstartSlug" $quickstartSlug "content" $content "sourceUrl" (index $example "sourceUrl") "binderId" $binderId }} {{ if gt (len $commands) 0 }} {{ $clientTab = merge $clientTab (dict "commands" $commands) }} {{ end }} {{ $tabs = $tabs | append $clientTab }} {{ end }} {{ end }} {{ $params := dict "id" (printf "%s-step%s" $id $step) "tabs" $tabs "showFooter" $showFooter "exampleId" $step "description" $description "difficulty" $difficulty }} {{ if gt (len $buildsUpon) 0 }} {{ $params = merge $params (dict "buildsUpon" $buildsUpon) }} {{ end }} {{ partial "tabs/wrapper.html" $params }}