docs-matrix-spec/layouts/shortcodes/event-fields.html
Richard van der Hoff 5f3b34448d
Add HTML ids for object definitions in the formatted specification (#1174)
* Remove redundant call to resolve-allof

All of the callers to resolve-additional-types already call resolve-allof (or
if not, they should), so this is redundant.

* Update `resolve-additional-types` to take a dict

I want to add more params to this, so first make it take a dict.

* `render-object-table`: take a "title" rather than a "caption"

... which means we can use the result from resolve-additional-types directly.

* render-object-table: support adding an anchor to generated tables.

* resolve-additional-types: generate an id for each returned type

* render-event: pass an anchor_base into resolve-additional-types

This means that it will generate an anchor for each type, whihc will then be
passed into render-object-table and used as an `id` for the table.

* render-operation: pass an anchor_base into resolve-additional-types

* newsfiles
2022-07-19 13:25:30 -06:00

45 lines
1.2 KiB
HTML

{{/*
This template is used to render the fields that all basic events and room events
must or may contain.
It expects to be passed an `event_type` parameter, is the name of a file under
/data/event-schemas/core-event-schema. The file extension is omitted. For example:
{{% event-fields event_type="room_event" %}}
This template replaces the old {{common_event_fields}} and {{common_room_event_fields}} templates.
*/}}
{{ $event := index .Site.Data "event-schemas" "schema" "core-event-schema" .Params.event_type }}
{{ $path := "event-schemas/schema/core-event-schema" }}
{{ $event = partial "json-schema/resolve-refs" (dict "schema" $event "path" $path) }}
{{ $event := partial "json-schema/resolve-allof" $event }}
<section class="rendered-data event">
<details {{ if not .Site.Params.ui.rendered_data_collapsed }}open{{ end }}>
<summary>
<h1>
<code>{{ humanize $event.title }}</code>
</h1>
<hr/>
{{ $event.description | markdownify }}
</summary>
{{ $event = merge $event (dict "title" "") }}
{{ $additional_types := partial "json-schema/resolve-additional-types" (dict "schema" $event) }}
{{ range $additional_types }}
{{ partial "openapi/render-object-table" . }}
{{end}}
</details>
</section>