apply changes from code review

pull/1283/head
Hubert Chathi 2 years ago
parent 089f1fee7d
commit d6345f0df2

@ -10,7 +10,7 @@ room itself such as a room name and topic.
#### Events
{{% event event="m.room.message" %}}
{{% event event="m.room.message" desired_example_name="m.room.message$m.text" %}}
{{% event event="m.room.name" %}}

@ -1,4 +1,13 @@
{{ $example_content := partial "json-schema/resolve-refs" (dict "schema" .example "path" "event-schemas/examples") }}
{{/*
Renders an event example. Resolves `$ref`s, serializes as JSON, and ensures
that it can be included in HTML.
This partial is called with the example data as its context.
*/}}
{{ $example_content := partial "json-schema/resolve-refs" (dict "schema" . "path" "event-schemas/examples") }}
{{ $example_json := jsonify (dict "indent" " ") $example_content }}
{{ $example_json = replace $example_json "\\u003c" "<" }}
{{ $example_json = replace $example_json "\\u003e" ">" | safeHTML }}

@ -22,7 +22,7 @@
<summary>
<h1 id="{{ anchorize $event_name }}">
{{ with .title }}{{ $.title | markdownify }}{{ else }}<code>{{ $event_name }}</code>{{ end }}
{{ with .title }}{{ . | markdownify }}{{ else }}<code>{{ $event_name }}</code>{{ end }}
</h1>
<hr/>
@ -74,10 +74,16 @@
*/}}
{{ if $desired_example_name }}
{{ if eq $example_name $desired_example_name }}
{{ partial "events/example" (dict "example" $example)}}
{{ partial "events/example" $example }}
{{ end }}
{{/*
If `$desired_example_name` is not given, we will include any
example that is equal to the event name. Normally, this would
be handled by the case below, but that case does not work if
the event name includes a "$".
*/}}
{{ else if eq $event_name $example_name }}
{{ partial "events/example" (dict "example" $example)}}
{{ partial "events/example" $example }}
{{/*
If `$desired_example_name` is not given, we will include any
examples whose first part (before "$") matches the event name
@ -87,7 +93,7 @@
{{ $pieces := split $example_name "$" }}
{{ $example_base_name := index $pieces 0 }}
{{ if eq $event_name $example_base_name }}
{{ partial "events/example" (dict "example" $example)}}
{{ partial "events/example" $example }}
{{ end }}
{{ end }}
{{ end }}

Loading…
Cancel
Save