apply changes from code review
This commit is contained in:
parent
089f1fee7d
commit
d6345f0df2
3 changed files with 21 additions and 6 deletions
|
@ -10,7 +10,7 @@ room itself such as a room name and topic.
|
||||||
|
|
||||||
#### Events
|
#### Events
|
||||||
|
|
||||||
{{% event event="m.room.message" %}}
|
{{% event event="m.room.message" desired_example_name="m.room.message$m.text" %}}
|
||||||
|
|
||||||
{{% event event="m.room.name" %}}
|
{{% 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 := jsonify (dict "indent" " ") $example_content }}
|
||||||
{{ $example_json = replace $example_json "\\u003c" "<" }}
|
{{ $example_json = replace $example_json "\\u003c" "<" }}
|
||||||
{{ $example_json = replace $example_json "\\u003e" ">" | safeHTML }}
|
{{ $example_json = replace $example_json "\\u003e" ">" | safeHTML }}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<summary>
|
<summary>
|
||||||
|
|
||||||
<h1 id="{{ anchorize $event_name }}">
|
<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>
|
</h1>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
@ -74,10 +74,16 @@
|
||||||
*/}}
|
*/}}
|
||||||
{{ if $desired_example_name }}
|
{{ if $desired_example_name }}
|
||||||
{{ if eq $example_name $desired_example_name }}
|
{{ if eq $example_name $desired_example_name }}
|
||||||
{{ partial "events/example" (dict "example" $example)}}
|
{{ partial "events/example" $example }}
|
||||||
{{ end }}
|
{{ 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 }}
|
{{ 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
|
If `$desired_example_name` is not given, we will include any
|
||||||
examples whose first part (before "$") matches the event name
|
examples whose first part (before "$") matches the event name
|
||||||
|
@ -87,7 +93,7 @@
|
||||||
{{ $pieces := split $example_name "$" }}
|
{{ $pieces := split $example_name "$" }}
|
||||||
{{ $example_base_name := index $pieces 0 }}
|
{{ $example_base_name := index $pieces 0 }}
|
||||||
{{ if eq $event_name $example_base_name }}
|
{{ if eq $event_name $example_base_name }}
|
||||||
{{ partial "events/example" (dict "example" $example)}}
|
{{ partial "events/example" $example }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue