content/static: example playground output fixes

The example playgrounds now clear the existing output before
printing new output when the Run button is pressed. Ensures
the loading message is cleared when example code produces no
output. Additionally, the output box will now display for all
examples because they are editable. Examples that don't
initially have output can be changed to produce output.

Change-Id: Ie70f98ab505a28705e2ea65869bddb84ef6927ec
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/295192
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jamal Carvalho 2021-02-22 18:02:29 -05:00
Родитель ad2db3f45c
Коммит 60c442b37e
4 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -14,9 +14,7 @@
<p><a class="Documentation-examplesPlay" href="{{.}}">Open in Go playground »</a></p>{{"\n" -}}
{{- end -}}
{{render_code .Example}}{{"\n" -}}
{{- if (or .Output .EmptyOutput) -}}
<pre><span class="Documentation-exampleOutputLabel">Output:</span>{{"\n\n"}}<span class="Documentation-exampleOutput">{{- .Output -}}</span></pre>{{"\n" -}}
{{- end -}}
<pre><span class="Documentation-exampleOutputLabel">Output:</span>{{"\n\n"}}<span class="Documentation-exampleOutput">{{- .Output -}}</span></pre>{{"\n" -}}
</div>{{"\n" -}}
{{- if .Play -}}
<div class="Documentation-exampleButtonsContainer">

Просмотреть файл

@ -118,6 +118,7 @@ export class PlaygroundExampleController {
if (Errors) {
this.setOutputText(Errors);
}
this.setOutputText('');
for (const e of Events || []) {
this.setOutputText(e.Message);
await new Promise(resolve => setTimeout(resolve, e.Delay / 1000000));

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -231,6 +231,7 @@ export class PlaygroundExampleController {
if (Errors) {
this.setOutputText(Errors);
}
this.setOutputText('');
for (const e of Events || []) {
this.setOutputText(e.Message);
await new Promise(resolve => setTimeout(resolve, e.Delay / 1000000));