aboutsummaryrefslogtreecommitdiff
path: root/static/doc/example.tmpl
diff options
context:
space:
mode:
authorHana Kim <hyangah@gmail.com>2026-03-05 21:38:22 -0500
committerHyang-Ah Hana Kim <hyangah@gmail.com>2026-03-12 07:19:18 -0700
commit61f82b0145f87d7397ea10c7c8a11ffadba25cb7 (patch)
tree69a3f82645c67c1a6f82ce9dae32138e6a108237 /static/doc/example.tmpl
parentebeca97f019584573944ae4bf09c50616b5565e7 (diff)
downloadgo-x-pkgsite-61f82b0145f87d7397ea10c7c8a11ffadba25cb7.tar.xz
static: display output container for runnable examples
Examples on pkg.go.dev that are runnable but lack pre-defined output previously did not display the output container when they were executed. This was because the template only rendered the output <pre> block conditionally if .Output was present. Modified static/doc/example.tmpl to always render the output container for runnable examples, hiding it by default if no initial output exists. Updated the PlaygroundExampleController in static/shared/playground/playground.ts to manage the visibility of this container when execution results are received. Added regression tests: - A client-side unit test in static/shared/playground/playground.test.ts - A server-side template test in internal/godoc/dochtml/dochtml_test.go Fixes golang/go#75062 Change-Id: I37b3922c99d956ff1b139834e4625eb8d61b84cd Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/752184 kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Ethan Lee <ethanalee@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'static/doc/example.tmpl')
-rw-r--r--static/doc/example.tmpl5
1 files changed, 4 insertions, 1 deletions
diff --git a/static/doc/example.tmpl b/static/doc/example.tmpl
index ab54b246..ece580cf 100644
--- a/static/doc/example.tmpl
+++ b/static/doc/example.tmpl
@@ -15,7 +15,10 @@
<p><a class="Documentation-examplesPlay" href="{{.}}">Open in Go playground ยป</a></p>{{"\n" -}}
{{- end -}}
{{render_code .Example}}{{"\n" -}}
- {{- if .Output -}}<pre><span class="Documentation-exampleOutputLabel">Output:</span>{{"\n\n"}}<span class="Documentation-exampleOutput">{{- .Output -}}</span></pre>{{"\n" -}}{{- end -}}
+ {{- if or .Output .Play -}}
+ <pre class="Documentation-exampleOutputContainer js-exampleOutputContainer"
+ {{- if not .Output}} hidden{{end}}><span class="Documentation-exampleOutputLabel">Output:</span>{{"\n"}}<span class="Documentation-exampleOutput">{{- .Output -}}</span></pre>{{"\n" -}}
+ {{- end -}}
</div>{{"\n" -}}
{{- if .Play -}}
<div class="Documentation-exampleButtonsContainer">