mirror of
https://github.com/matrix-org/matrix-spec
synced 2025-12-20 16:38:37 +01:00
* Add tr as child of thead in HTML tables It is invalid HTML for th to be the direct children of thead Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Remove unnecessary HTML code end tag Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Avoid nesting p HTML elements A p HTML element cannot contain other block elements, so the "parent" element is closed when the first "child" one is opened. We need to use Page.RenderString with options to force Hugo to keep the wrapping p elements even if the content contains a single paragraph. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Add missing HTML details end tags Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Replace HTML a self-closing tag with start and end tags The a element start and end tags are mandatory. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Replace obsolete HTML name attribute with id Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr> * Add changelog Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
107 lines
3.1 KiB
HTML
107 lines
3.1 KiB
HTML
{{/*
|
|
|
|
Renders a single event, given:
|
|
|
|
* `event_name`: the name to use for the event
|
|
* `event_data`: the event specification
|
|
* `desired_example_name` (optional): the exact name of the examples to render.
|
|
If `desired_example_name` is omitted we render all examples
|
|
whose names start with the `event_name`.
|
|
* `title` (optional): the title to display. May contain markdown. Defaults to
|
|
`event_name` wrapped in a <code> element.
|
|
|
|
*/}}
|
|
|
|
{{ $event_name := .event_name }}
|
|
{{ $desired_example_name := .desired_example_name }}
|
|
{{ $event_data := .event_data }}
|
|
|
|
<section class="rendered-data event">
|
|
|
|
<details {{ if not .Site.Params.ui.rendered_data_collapsed }}open{{ end }}>
|
|
<summary>
|
|
|
|
<h1 id="{{ anchorize $event_name }}">
|
|
{{ with .title }}{{ . | markdownify }}{{ else }}<code>{{ $event_name }}</code>{{ end }}
|
|
</h1>
|
|
|
|
</summary>
|
|
|
|
<hr/>
|
|
|
|
{{ if (index $event_data "x-addedInMatrixVersion") }}
|
|
{{ partial "added-in" (dict "v" (index $event_data "x-addedInMatrixVersion")) }}
|
|
{{ end }}
|
|
{{ if (index $event_data "x-changedInMatrixVersion") }}
|
|
{{ partial "changed-in" (dict "changes_dict" (index $event_data "x-changedInMatrixVersion")) }}
|
|
{{ end -}}
|
|
|
|
{{ $event_data.description | markdownify }}
|
|
|
|
{{ $state_key := index $event_data.properties "state_key" }}
|
|
|
|
<table class="basic-info">
|
|
<tr>
|
|
<th>Event type:</th>
|
|
<td>{{ if $state_key }}State event{{ else }}Message event{{ end }}</td>
|
|
</tr>
|
|
{{ if $state_key }}
|
|
<tr>
|
|
<th>State key</th>
|
|
<td>{{ $state_key.description | markdownify }}</td>
|
|
</tr>
|
|
{{ end }}
|
|
</table>
|
|
|
|
<h2>Content</h2>
|
|
|
|
{{ $anchor_base := anchorize $event_name }}
|
|
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict
|
|
"schema" $event_data.properties.content
|
|
"anchor_base" $anchor_base
|
|
) }}
|
|
|
|
{{ range $additional_types }}
|
|
{{ partial "openapi/render-object-table" . }}
|
|
{{end}}
|
|
|
|
<h2>Examples</h2>
|
|
|
|
{{ $all_examples := index site.Data "event-schemas" "examples" }}
|
|
|
|
{{ range $example_name, $example := $all_examples }}
|
|
|
|
{{/*
|
|
This is to allow the msgtype template to work.
|
|
It lets callers specify exactly the name of the example they want
|
|
*/}}
|
|
{{ if $desired_example_name }}
|
|
{{ if eq $example_name $desired_example_name }}
|
|
{{ partial "events/example" (dict "schema" $example "name" $example_name) }}
|
|
{{ 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 "schema" $example "name" $example_name) }}
|
|
{{/*
|
|
If `$desired_example_name` is not given, we will include any
|
|
examples whose first part (before "$") matches the event name
|
|
*/}}
|
|
{{ else }}
|
|
|
|
{{ $pieces := split $example_name "$" }}
|
|
{{ $example_base_name := index $pieces 0 }}
|
|
{{ if eq $event_name $example_base_name }}
|
|
{{ partial "events/example" (dict "schema" $example "name" $example_name) }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
</details>
|
|
|
|
</section>
|