Skip to content

Commit fb9eebf

Browse files
authored
Merge pull request #47976 from r21gh/fix-47934
Fix 'feature-state' shortcode for accurate rendering in tabs
2 parents 23e2c03 + 44e798a commit fb9eebf

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

layouts/shortcodes/feature-state.html

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,48 @@
11
{{ $valid_states := "alpha, beta, deprecated, stable" }}
22
{{ $state := .Get "state" }}
3-
{{ $for_k8s_version := .Get "for_k8s_version" | default (.Page.Param "version")}}
3+
{{ $for_k8s_version := .Get "for_k8s_version" | default (.Page.Param "version") }}
44
{{ $is_valid := strings.Contains $valid_states $state }}
55
{{ $feature_gate_name := .Get "feature_gate_name" }}
66

7-
<!-- When 'feature_gate_name' parameter is not specified, continue with the values provided. -->
87
{{ if not $feature_gate_name }}
98
{{ if not $is_valid }}
109
{{ errorf "%q is not a valid feature-state, use one of %q" $state $valid_states }}
1110
{{ else }}
12-
<div class="feature-state-notice feature-{{ $state }}">
13-
<span class="feature-state-name">{{ T "feature_state" }}</span> <code>{{T "feature_state_kubernetes_label" }} {{ $for_k8s_version }} [{{ $state }}]</code>
14-
</div>
11+
<div class="feature-state-notice feature-{{ $state }}">
12+
<span class="feature-state-name">{{ T "feature_state" }}</span>
13+
<code>{{ T "feature_state_kubernetes_label" }} {{ $for_k8s_version }} [{{ $state }}]</code>
14+
</div>
1515
{{ end }}
16-
17-
{{- else -}}
18-
<!-- When 'feature_gate_name' is specified, the following code block extracts the status of the feature gate from the description file. -->
19-
20-
<!-- Set the path for feature gate description files -->
16+
{{ else }}
17+
<!-- When 'feature_gate_name' is specified, extract status of the feature gate -->
18+
2119
{{- $featureGateDescriptionFilesPath := "/docs/reference/command-line-tools-reference/feature-gates" -}}
22-
23-
<!-- Access the 'English' site and get the feature gate description pages -->
20+
2421
{{- with index (where .Site.Sites "Language.Lang" "eq" "en") 0 -}}
2522
{{- with .GetPage $featureGateDescriptionFilesPath -}}
2623

27-
<!-- Sort Feature gate pages list -->
2824
{{- $sortedFeatureGates := sort (.Resources.ByType "page") -}}
2925
{{- $featureGateFound := false -}}
3026

31-
<!-- Iterate through feature gate files -->
3227
{{- range $featureGateFile := $sortedFeatureGates -}}
3328
{{- $featureGateNameFromFile := $featureGateFile.Params.Title -}}
3429

3530
{{- if eq $featureGateNameFromFile $feature_gate_name -}}
36-
<!-- Extract information from the final stage of the feature gate -->
3731
{{- $currentStage := index $featureGateFile.Params.stages (sub (len $featureGateFile.Params.stages) 1) -}}
3832
{{- with $currentStage -}}
39-
40-
<!-- Display feature state information -->
41-
<div class="feature-state-notice feature-{{ .stage }}" title="{{ printf "%s %s" (T "feature_state_feature_gate_tooltip") $feature_gate_name }}">
42-
<span class="feature-state-name">{{ T "feature_state" }}</span> <code>{{T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]</code>
43-
</div>
33+
34+
<div class="feature-state-notice feature-{{ .stage }}" title="{{ printf "%s %s" (T "feature_state_feature_gate_tooltip") $feature_gate_name }}">
35+
<span class="feature-state-name">{{ T "feature_state" }}</span>
36+
<code>{{ T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]</code>
37+
</div>
4438

4539
{{- $featureGateFound = true -}}
4640
{{- end -}}
4741
{{- end -}}
4842
{{- end -}}
4943

50-
<!-- Check if specified feature gate is not found -->
5144
{{- if not $featureGateFound -}}
52-
{{- errorf "Invalid feature gate: '%s' is not recognized or lacks a matching description file in '%s'" $feature_gate_name (print "en" $featureGateDescriptionFilesPath) -}}
45+
{{- errorf "Invalid feature gate: '%s' is not recognized or lacks a matching description file in '%s'" $feature_gate_name (print "en" $featureGateDescriptionFilesPath) -}}
5346
{{- end -}}
5447

5548
{{- end -}}

0 commit comments

Comments
 (0)