{{/*

  This template is used to render a group of events starting with a given prefix.

  It expects to be passed a `group_name` parameter. For example:

      {{% event-group group_name="m.call" %}}

  The template will then render all events whose schema starts with the given name.

  This template replaces the old {{*_events}} template.

*/}}

{{ $path := "event-schemas/schema" }}

{{ $events := index .Site.Data "event-schemas" "schema" }}
{{ $group_name := .Params.group_name }}

{{ range $event_name, $event_data := $events }}

    {{ $prefix := substr $event_name 0 (len $group_name) }}
    {{ if eq $prefix $group_name }}

        {{ $event_data = partial "json-schema/resolve-refs" (dict "schema" $event_data "path" $path) }}
        {{ $event_data := partial "json-schema/resolve-allof" $event_data }}

        {{ partial "events/render-event" (dict "event_name" $event_name "event_data" $event_data)}}

    {{ end }}

{{ end }}
